pluploader update url from input value

25 Views Asked by At

I have a page with a file tree from where users can select a directory or sub-directory to where they wish to upload files using pluploader. I have the following code:

if($("#uploader_v5").length > 0){
        $("#uploader_v5").pluploadQueue({       
                runtimes : 'html5',
                url : 'pluploader/upload_to_directory.php',
                max_file_size : '3mb',
                chunk_size : '3mb',
                unique_names : false,
                dragdrop : true,
                rename: true,
                filters : [
                        {title : "Document files", extensions : "pdf,php,html,xml"},
                        {title : "Image files", extensions : "jpg,gif,png"}
                ],
                
                FilesAdded: function(editor,files){
                    alert(files);
                }
        });
    }

Now I need to pass the chosen directory path to the url, eg. pluploader/upload_to_directory.php?directory=[chosen directory path]

When a user click on a directory in the file tree, the value of a hidden input is updated with the full path.

So far it seems I'll need to add something like the code below:

$("#uploader_v5").bind('BeforeUpload', function(uploader, file) {
    uploader.settings.url = "pluploader/upload_to_directory.php?directory=[chosen directory]";
});

But I have absolutely no idea how to replace [chosen directory] with the value of the hidden input.

I've tried the following:

$("#uploader_v5").bind('BeforeUpload', function(uploader, file) {
    var directory = $('#directory').attr('id');
    uploader.settings.url = "pluploader/upload_to_directory.php?directory=" + directory;
});

The above gives me an undefined variable error for directory.

My knowledge of jQuery is very limited, so it may be something very simple, or perhaps an entire different way?

0

There are 0 best solutions below