Set file path for input type="file"

Issue

Can we set the file path in javascript for

<input name="pictureUL" type="file" value="upload" onChange="this.form.submit()"/>

without opening the select file dialog box?
I have 2 buttons SCAN and FIND. ADD button opens dialog box asking user to select the file which will be uploaded to the server. SCAN button has to scan the document and upload it to the server. Scanning is fine but to submit the form i need to set the file path in the file tag as i am submitting the form there. Is there a way to do it?
Thanks in advance.

Solution

Due to possibly security issues, modern browsers do not allow you to access the file path or modify the value of an <input type="file">. You also cannot view the file path, as it will display C:\fakepath\yourfilename.yourfilextension.

Answered By – AstroCB

Answer Checked By – Marie Seifert (AngularFixing Admin)

Leave a Reply

Your email address will not be published.