I'm using the very good jquery plugin blueimp / jQuery-File-Upload
$('#fileupload').fileupload({
autoUpload: true
, filesContainer: '#attachments_presentation tbody'
, stop: function (e) {
console.log(data);
}
});
And I'm not able to do something very simple: get the list of uploaded files
(with their name on the server)
Firstly I naively though it would be stored on the file input so I could get the list with
$('#fileupload').val();
But it's not, so I though about something like
$('#fileupload').fileupload('getfiles');
I can't find the way from the docs
Can somebody tell me how I can get the list of uploaded file names in the server ?
Update
I'd like to get the uploaded files name on the server in order to be able to manage them afterwards.
For example:
- I upload a file named
trutruc.pdf
- I upload
test.png
- I re-upload a file named
trutruc.pdf
- I delete the first file
The current list of files in the server should then be test.png
, trutruc (2).pdf
Update 2
I'm using the default php script shipped with fileUpload
To get the list of uploaded file names from the server, requires server-side code:
UploadHandler.php is used to upload files to a directory/s on your server.
If you've downloaded the plug-in archive and extracted it to your server, the files will be stored in php/files by default. (Ensure that the php/files directory has server write permissions.) see: https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
UploadHandler.php is just that, an upload handler. It does not provide access to server files without a connection to the server.
JavaScript cannot access files on the server, so you'll need a php script to do so. (Although JavaScript could possibly keep track of everything uploaded, renamed, and deleted.)
You can modify UploadHandler.php to connect to your database, and write the file paths (and any other data) to a files table during upload. Then you can access your files via standard SQL queries:
Modify UploadHandler.php:
see: https://github.com/blueimp/jQuery-File-Upload/wiki/Working-with-databases
you can also try this
Well this is quite an old post, but this is something which worked very well for me so I thought to post it.
Bind the event to FileUploader (I did it in main.js):
In your html file, use the following code to get the file name:
You should watch the data object in firebug. This object encapsulates most of the information.
try use done method and put names in hidden input then select them: