jquery-file-upload 插件:如何更改上传路径?

发布于 2025-01-07 16:45:54 字数 652 浏览 0 评论 0原文

我正在尝试使用 blueimp jquery-file-upload 插件。 似乎是一个很好的上传器,但文档没有帮助。

当我使用可下载的演示脚本时,一切正常。 但是,当我想更改上传路径时,这不起作用。

我尝试在index.php中更改操作路径,如下所示:

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

并在我的“上传”文件夹中添加文件夹“文件”和“缩略图”。

GET 调用没问题,正如我在 Firebug 中看到的那样:

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

但是当我启动上传操作时,POST 回答了我(仍在 Firebug 中):

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

我没有更改任何其他内容。 我忘记了什么?

为什么 GET 调用可以看到文件夹,但 POST 调用看不到?

提前致谢。 此致。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桜花祭 2025-01-14 16:45:54

虽然 @mugur 提供的答案是正确的,但查看库提供的 php 类,构造方法中的第一个参数是“选项”,并按如下方式声明关联数组:

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

并在实例化该类时将其作为第一个参数传递:

$upload_handler = new UploadHandler($options);

将允许您在每次使用该类时更改上传目录,而不是更改源代码。

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.

掩于岁月 2025-01-14 16:45:54

表单操作不是您的上传文件夹所在的文件夹。表单操作是提交后发送数据的脚本。 信息 http://www.w3schools.com/tags/att_form_action.asp

(在此处查看有关表单操作的更多 找到上传的目标文件夹或查看脚本内部。

更新:下载库后

您应该查看 server/php/upload.class.php,其中有一些带有上传文件夹位置的变量:

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

Tou 应该替换 /files/< /code> 与您自己的上传文件夹。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文