I ended up doing this to file with the uploadify function on it:
var path;
$("#file_upload").uploadify({
'buttonText' : 'Upload New Files',
'height' : 30,
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'uploadify/uploadify.php',
'width' : 120,
'folder' : $('#folder').val(),
'auto' : true,
'multi' : true,
'folder' : path,
'onUploadStart' : function(file) {
$('#file_upload').uploadify("settings", 'formData', {'folder' : path});
},
'onUploadSuccess' : function(file, data, response) {
//alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
location.reload();
}
});
$("#folder").change(function () {
path = "/" + $(this).val();
});
And on uploadify.php I changed it to this:
//$targetFolder = '/file/downloads'; // Relative to the root
$targetFolder = "/file".$_POST['folder'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png','pdf','doc','docx'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo $targetFolder;
} else {
echo 'Invalid file type.';
}
}
And now it works :D