Jquery文件上传插件:动态更改上传路径?

时间:2022-12-09 19:58:09

I'm trying to use the blueimp Jquery File Upload plugin for the project I'm currently working on. It suits my needs perfectly, with one problem: I need to be able to change the path of the uploads, based on a GET variable on the page that contains the plugin. Basically, I'm using it as an image manager for a collection of vehicles, and I want it to connect to a separate folder for each vehicle.

我正在尝试使用blueimp Jquery File Upload插件来处理我目前正在进行的项目。它完全符合我的需求,有一个问题:我需要能够根据包含插件的页面上的GET变量来更改上传的路径。基本上,我将它用作车辆集合的图像管理器,我希望它连接到每个车辆的单独文件夹。

I've been looking through the documentation and googling, and I've found the way to change the default directory (by modifying upload.class.php) but since I need this to be dynamic, that doesn't work.

我一直在浏览文档和谷歌搜索,我已经找到了更改默认目录的方法(通过修改upload.class.php),但由于我需要这是动态的,这是行不通的。

I figure there has to be a way to add a POST variable to the ajax calls which activate the php scripts, but I can't even find out where those ajax calls are. I can't even find a reference to either of the php files (index.php and upload.class.php) throughout the code.

我认为必须有一种方法可以将一个POST变量添加到激活php脚本的ajax调用中,但我甚至无法找到那些ajax调用的位置。我甚至无法在整个代码中找到对任何一个php文件(index.php和upload.class.php)的引用。

Any ideas on how to accomplish this?

有关如何实现这一目标的任何想法?

1 个解决方案

#1


5  

In your form, add a field like this:

在表单中,添加如下字段:

<input type="hidden" name="path" value="<?echo $_GET['path'];?>">

And in your PHP where the file is uploading, just extract the path with:

在您上传文件的PHP中,只需提取路径:

$path = $_POST['path'];

Just put the path where it is specified in the PHP script.

只需将路径放在PHP脚本中指定的位置即可。

#1


5  

In your form, add a field like this:

在表单中,添加如下字段:

<input type="hidden" name="path" value="<?echo $_GET['path'];?>">

And in your PHP where the file is uploading, just extract the path with:

在您上传文件的PHP中,只需提取路径:

$path = $_POST['path'];

Just put the path where it is specified in the PHP script.

只需将路径放在PHP脚本中指定的位置即可。