jquery-file-upload plugin : How to change the uplo

2020-05-26 04:15发布

I'm trying to work with the blueimp jquery-file-upload plugin. Seems to be a good uploader, but the documentation is not helpful.

When I work with the downloadable demo script, all is ok. But, when I want to change the upload path, that doesn't work.

I've tried to change, in index.php, the action path, like this :

form id="fileupload" action="../uploads/" method="POST" enctype="multipart/form-data"

and added the folders "files" and "thumbnails" in my "uploads" folder.

The GET call is ok, as I can see in Firebug :

GET http://localhost/alliance_pretests/uploads/ 200 OK -8ms

But when I launch the upload action, the POST answers me (still in Firebug) :

POST http://localhost/alliance_pretests/uploads/ 404 Not Found 44ms

I didn't change anything else. What did I forget ?

Why the GET call sees the folder, but not the POST call ?

Thanks in advance. Best regards.

2条回答
贪生不怕死
2楼-- · 2020-05-26 04:31

The form action is not the folder where your upload folder should be. The form action is the script where the data is sent after submitting. (see more here about form actions http://www.w3schools.com/tags/att_form_action.asp)

Try finding a destination folder for uploads or look inside the script for that.

Update: after downloading the library

You should look in server/php/upload.class.php and there you have some variables with the location of the upload folder:

'script_url' => $this->getFullUrl().'/',
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/',
'upload_url' => $this->getFullUrl().'/files/',

Tou should replace /files/ with your own upload folder.

查看更多
We Are One
3楼-- · 2020-05-26 04:56

Although the answer @mugur supplied is correct, looking at the php class supplied with the library the first parameter in the construct method is "options" and by declaring an associative array as follows:

$options = array('upload_dir'=>'upload/directory/of/your/choice', 'upload_url'=>'upload/directory/of/your/choice');

and passing it as the first parameter when instantiating the class:

$upload_handler = new UploadHandler($options);

Will allow you to change the upload directory every time you use the class rather than altering the source code.

查看更多
登录 后发表回答