0

I have been reading the Jquery file upload wiki, but did not come across an example on how to modify the server upload folder on the fly. Is there a working example on how to programmatic modify the php server upload directory?

4
  • 1
    It's a config directive. Any particular reason why you need to do it programmatically? I don't think you'll be able to, as your code doesn't even begin to execute until the file upload is finished. You have to move the file later.
    – Brad
    Commented May 1, 2013 at 3:07
  • @Brad, The reason that I would like to achieve that is, I have multiple folders that I would like to upload the files to. I created a combobox that lists directories. I would like to select the specific directory then press upload. I am thinking that I should pass form data then create a php script to move the specific file to the directory that has been chosen from the combobox. Do you have another idea that I can implement to achieve that goal?
    – dottedquad
    Commented May 1, 2013 at 3:17
  • 3
    I would not change the upload directory. Just pass a variable along with the POST that tells your server side script where to place the file
    – Matt
    Commented May 1, 2013 at 3:20
  • 1
    @dottedquad, Yes, just move the file afterwards. Who cares where the temporary file goes.
    – Brad
    Commented May 1, 2013 at 3:25

1 Answer 1

0

This is basically off the JQuery Fileupload docs with a little more explanation by me.

//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;
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.