I have been working with the blueimp jQuery File Upload plugin and I'm trying to setup a custom field the user can change for uploads.
Within the PHP class there is a construct which sets up all the default options variables. I'm looking for the best way I can store this data so after the user sets a value it'll save as the new default upload folder. I'm thinking inside an external XML file, which is them imported into the PHP script.
Here's the upload class constructor function:
function __construct($options=null) {
$this->options = array(
'script_url' => $this->getFullUrl().'/',
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/',
I hope this makes sense and I'm happy to clarify anything. But basically - how can I allow users to manually enter a directory structure and that becomes the new upload directory for images? Where could I save this new string variable? Probably not inside PHP but possibly in an external file, like XML or JSON?
I noticed you and I posted a blueimp upload issue on github at about the same time. I'm not sure I have a complete answer for you, but let me give you what I've found so far. Maybe it will help:
I have been looking for a way to filter uploaded files by user from within an authenticated system. I posted github.com/blueimp/jQuery-File-Upload/issues/1578 . The plugin author suggested that I filter on the server side. I found github.com/blueimp/jQuery-File-Upload/issues/1149 which explains how to filter on the server side. I've done this and it works as far as uploading. I now have it setup where each user has a subfolder in the upload folder named their unique ID number which contains their images. So anyway, this is a dynamic way to set the upload path. Maybe you can use it.
My current problem is that although I can confirm that the images are uploaded they are not visible in the download table. Please see github.com/blueimp/jQuery-File-Upload/issues/1587 .
One attempt I've made to fix this included trying to pass options into the constructor:
Here is my code in the blueimp index.php file:
$customer_path_files = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR. 'files' . DIRECTORY_SEPARATOR . $uid . DIRECTORY_SEPARATOR;
if (!file_exists($customer_path_files)) {
@mkdir($customer_path_files);
}
$customer_path_thumbnails = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $uid . DIRECTORY_SEPARATOR;
if (!file_exists($customer_path_thumbnails)) {
@mkdir($customer_path_thumbnails);
}
$options=array(
'upload_dir' => $customer_path_files,
'upload_url' => base_url().'blueimp/server/php/files/'.$uid.'/',
'thumbnail' => array(
'upload_dir' => $customer_path_thumbnails,
'upload_url' => base_url().'blueimp/server/php/thumbnails/'.$uid.'/',
'max_width' => 80,
'max_height' => 80
)
);
require('upload.class.php');
$upload_handler = new uploadHandler($options);
Hope something here helps,
Addendum:
I hope it does. BTW I read Jquery File Upload plugin: Dynamically change upload path?. That is exactly what I am trying to do. In case you are too, let me just say that I also tried to pass the session variable ( in my case the codeigniter variant ( $this->session->userdata('uid') ) in a hidden field to the plugin's index.php file, but just like in the post , it doesn't exist in index.php ( I think because , the upload button is not pushed for the repopulation or delete ). This is my first experience with ajax, but I think that the session ID must somehow be sent via Json. I'm trying to figure that out. It sounds like That's what Chris G did. If its any help I've posted the following question with some more details: