how can i change the upload directory?
i want to change the file upload directory dynamically
f.g : for each user,upload files to her/his folder
thanks
You can store the directory in a $_SESSION variable or in a $_COOKIE , and then get the saved value in the file /php/index.php
$uplDir = $_SESSION["uploadDirectory"].'/;
$option = array(
/* some options */
'upload_dir' => $uplDir,
/* .... */
);
$upload_handler = new UploadHandler($option);
ps. remember the session_start(); at the beginning
You can send that via parameters in the form data in js file
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json',
formData: [{ name: 'custom_dir', value: '/save/file/here/' }],
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
//=========================
while in the upload handler definition
require('UploadHandler.php');
$custom_dir = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['custom_dir'];
$upload_handler = new UploadHandler(array('upload_dir' => $custom_dir));