SoAanyip / React-FileUpload

Upload files async with xhr2 or iframe for IE. Supporting IE8+. React component.
310 stars 95 forks source link

IE9 issue: cannot get property 'length': object is null or undefined #24

Open dlvx opened 7 years ago

dlvx commented 7 years ago

This error is happening to me when trying to add an attatchment while on IE9. Clicking the add attatchment button will display the file explorer, after selecting any file the error is displayed in the browser console. This means I cannot do any upload on IE9 so far.

PD: IE11 and Chrome are working fine as expected

dlvx commented 7 years ago

Was able to do a workaround for this, adding the following validation on the chooseFile handler:

   let filename = null
        if(typeof files === 'string' && files !== null){ //In IE9, files is only a string containing the filename
            filename = files
        }else{ //In modern browsers, we get an object with the file's metadata
            filename = files[0].name
     }
    ...And then store that filename in the state