uploader
uploader copied to clipboard
Name of Saved File
Hi,
Thanks for a great plugin. I'm using the basic demo version and it's perfect except for one thing: how do I get the name of the file on the server? I figure I can use the template function to insert it in a data property, but I need help getting the saved name.
Kind regards, Tim
same here
I managed to resolve this myself, so here are the steps, so as to help anyone else with the same problem:
- Create a holder for the file name
- In the "files-template" section (within your HTML) add the attribute data-filepath="" to the li class="media" element
- Send the data to the template function on successful upload
- In the "demo-config.js" file find the "onUploadSuccess" function
- replace the line that says ui_multi_update_file_status(id, 'success', 'Upload Complete'); with ui_multi_update_file_status2(id, 'success', 'Upload Complete', JSON.stringify(data));
- Populate the template field
- In the "demo-ui.js" file add the following function: function ui_multi_update_file_status2(id, status, message, response) { $('#uploaderFile' + id).find('span').html(message).prop('class', 'status text-' + status); // EXTRACT SAVED FILE NAME FROM RESPONSE var searchString = "files/"; var indexBegin = response.indexOf(searchString) + searchString.length; var lengthResult = response.length - indexBegin - 2; var filePath = response.substr(indexBegin, lengthResult); // SET VALUE IN TEMPLATE $('#uploaderFile' + id).attr("data-filepath", filePath); }
Easy when you know how ;)