jquery文件上传:如何在提交前更改服务器上传文件

时间:2013-05-01 03:06:10

标签: php jquery file-upload

我一直在阅读Jquery文件上传维基,但没有遇到如何动态修改服务器上传文件夹的示例。是否有一个关于如何编程修改php服务器上传目录的工作示例?

1 个答案:

答案 0 :(得分:0)

这基本上是关于JQuery Fileupload文档的,我做了一点解释。

//You should bind this to the same object you setup the fileupload on
$('#fileupload').bind('fileuploadsubmit', function (e, data) {
    // The example input, doesn't have to be part of the upload form
    var input = $('#inputWithVariable');

    //Add the new value as a variable called "folder" which will tell you which
    //directory they selected
    data.formData = {folder: input.val()};

    //Optional validation to make sure the input value exists
    if (!data.formData.example) {

     //If the value does not exist, return focus to the input 
     //or maybe select in your case and return false to prevent the upload
      input.focus();
      return false;
    }
});