Changing the upload dir dynamically

1,670 views
Skip to first unread message

Mike Wes

unread,
Feb 2, 2013, 11:28:17 AM2/2/13
to jquery-f...@googlegroups.com
Good day,

I have a question. I am running JQuery File Upload inside a iframe. How can I modify the directories dynamically?
I tried a $_REQUEST['id'] for variable upload_dir and upload_url at the __construct(...) without success.

What do I do wrong? Any ideas?

regards,

Mike

Stephen Davies

unread,
Feb 2, 2013, 11:39:02 AM2/2/13
to jquery-f...@googlegroups.com
How and where are you setting the 'id' ?. Have you tried POST or GET in UploadHandler.php. It works for me.

Rayvionne French

unread,
Feb 2, 2013, 12:30:53 PM2/2/13
to jquery-f...@googlegroups.com
I'm having the same issue... I have searched through maybe 30 different threads about this plug and NOT A SINGLE ONE HAS HELPED. I have a hidden input field in the upload form:

<form id="fileupload" ...
.
.
<input type="hidden" id="path" name="path" value="videos/" >
.
.

And according to the plugin's author, this field's data gets sent by default. If so, then why can't I retrieve it in UploadHandler.php? I've tried $_GET, $_POST, and $_REQUEST arrays. The 'path' key is NEVER set.
I'm sure this is the easiest thing in the world and a ton of people have done the same thing I want to do. But I have yet to find a simple (working) step-by-step.

Ray
Message has been deleted

Stephen Davies

unread,
Feb 3, 2013, 9:34:09 AM2/3/13
to jquery-f...@googlegroups.com
One of the following should work.

<?php echo $_REQUEST['path']; ?>

Or

<?php echo $_POST['path']; ?>

Or

<?php echo $_GET['path']; ?>

But I would suggest SESSION to set the path for better security.

On the form page.

session_start();  // Set the path
$_SESSION['path'] = "/your/path/here";


In UploadHandler.php

session_start();  // Get the path
$path = $_SESSION['path'];

Mike Wes

unread,
Feb 9, 2013, 7:43:07 AM2/9/13
to jquery-f...@googlegroups.com
I looked to it today and is is working!

The UploadHandler.php is now:

session_start();
$path
= $_SESSION['path'];


........
   
function __construct($options = null, $initialize = true) {
        $this
->options = array(
           
'script_url' => $this->get_full_url().'/',
           
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/'.$_SESSION['path'].'/',
           
'upload_url' => $this->get_full_url().'/files/'.$_SESSION['path'].'/',

THANKS!

Regards,

Mike





Op zondag 3 februari 2013 15:34:09 UTC+1 schreef Stephen Davies het volgende:

Thomas May

unread,
Mar 19, 2013, 3:13:32 AM3/19/13
to jquery-f...@googlegroups.com
Hi guys,

i changed in js/main.js url: to empty:'

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: '',
        maxFileSize: 5000000 // 5 MB
    });

after that if i change the input data-url it will also work

input id="fileupload" type="file" name"files[]" data-url="your new path" multiple>

regards, thomas












Reply all
Reply to author
Forward
0 new messages