1

Now, i use Blueimp jQuery File Upload to upload files. I have a question how can i upload in custom folder?. Example: with defaullt Blueimp jQuery File Upload will upload to folder server/php/files and server/php/files/thumbnail. I want to add custom param when upload and it will upload to this folder. Ex: i set it will up load to abc, file upload will upload to folder server/php/files/abc and server/php/files/thumbnail/abc. I had change data-url in input but it doesnt change More: in page A i will upload to folder abc,in page B i will upload to folder cde

<input id="fileupload" type="file" name="files[]" data-url="/assets/server/php/abc" multiple>

<script>
$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        add: function (e, data) {
            data.context = $('<p/>').text('Uploading...').appendTo(document.body);
            data.submit();
        },
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
                console.log(file);
            });
        }
    });
});
</script>

2 Answers 2

1

i just went through the class of the Blueimp jQuery File Uploader. just change the option below to whatever folder you want..

'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',

Sign up to request clarification or add additional context in comments.

3 Comments

Can you post full script? I had pasted it but can't run
public function __construct($options = null, $initialize = true, $error_messages = null) { $this->response = array(); $this->options = array( 'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')), 'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/', 'upload_url' => $this->get_full_url().'/files/', 'input_stream' => 'php://input', 'user_dirs' => false, 'mkdir_mode' => 0755, 'param_name' => 'files',
0

I did it by passing in options to the UploadHandler contructor: I changed downloads/server/php/index.php to contain:

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
/* the constructor checks method, and performs GET or POST respectively */
$upload_handler = new UploadHandler(array('upload_dir' => '/var/www/html/downloads/',
                                          'upload_url' => '/downloads/',
                                          ...));

(... stands for other options I wanted that you might not care about.)

Comments

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.