Вопрос

I am using nicedit.js as my website content editor. So I want to know how to change the image uploading location and how to create php file to do it.

There is a file given by the http://nicedit.com Here is the script: http://svn.nicedit.com//trunk/nicUpload/php/nicUpload.php

But it doesn't work. Still show message "Failed to upload image".

Это было полезно?

Решение

Here is something I have done with nicupload.php. Find this line. Define your path.

define('NICUPLOAD_PATH', '../uploads');


if($_SERVER['REQUEST_METHOD']=='POST') { // Upload is complete

    $file = $_FILES['image'];
    $image = $file['tmp_name'];
    $id = $file['name'];

    $max_upload_size = ini_max_upload_size();
    if(!$file) {
        nicupload_error('Must be less than '.bytes_to_readable($max_upload_size));
    }

    $ext = strtolower(substr(strrchr($file['name'], '.'), 1));
    @$size = getimagesize($image);
    if(!$size || !in_array($ext, $nicupload_allowed_extensions)) {
        nicupload_error('Invalid image file, must be a valid image less than '.bytes_to_readable($max_upload_size));
    }

    $filename = $id;
    $path = NICUPLOAD_PATH.'/'.$filename; /*****Path must be set here*******/

    if(!move_uploaded_file($image, $path)) {
        nicupload_error('Server error, failed to move file');
    }

    $status = array();
    $status['done'] = 1;
    $status['width'] = $size[0];
    $rp = realpath($path);
    $status['url'] =  NICUPLOAD_URI ."/".$id;


    nicupload_output($status, false);
    exit;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top