Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
IgUpload Get FIle name on error
posted

I have the following code below. I am doing multiple uploads using the control. If anyone of those files should exceed the max upload file size I need to display an error.

"testFileName.txt exceeds max upload size of 15 MB"

Is there an easy way to do this? I have searched the forums and have not found anything. The solution we have come up with is overly complex. I feel like there is a simple solution that we are missing.

  $(document).delegate("#fileNetUpload", "iguploadonerror", function (evt, ui) {
  var filename = "How to get file name"
    if (ui.errorMessage == 'Max file size exceeded.')
           {
                $("#error-message").append("<p>" + fileName + " " + 'exceeds max upload size of 15 MB' + "</p>");

            }
            else { $("#error-message").append("<p>" + ui.errorMessage + "</p>"); }
    });

Parents
  • 280
    Suggested Answer
    posted

    The easiest way to I have found to achieve this is to use a global variable, I name fileIndex.

    On each successful file upload and when an error is generated it increments the value.

    Inside of the error we call  var fileInfo = $("#fileNetUpload").igUpload("getFileInfo", fileIndex);

    then we use fileInfo.path to get the file name.

    There is some additional logic required to get the fileIndex value to reference the correct file in the array.

    This works but it still seems like there should be a cleaner way to do this.

Reply Children