Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name of Saved File #104

Open
Donkeh68 opened this issue Oct 11, 2019 · 2 comments
Open

Name of Saved File #104

Donkeh68 opened this issue Oct 11, 2019 · 2 comments

Comments

@Donkeh68
Copy link

Donkeh68 commented Oct 11, 2019

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

@sahuadarsh0
Copy link

same here

@Donkeh68
Copy link
Author

Donkeh68 commented Oct 22, 2019

I managed to resolve this myself, so here are the steps, so as to help anyone else with the same problem:

  1. 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
  1. 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));
  1. 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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants