is there any way that html element file
<input name="file1" type="file" style="width:300px">
only accept PDF files and when we browse its only show PDF files...
Thanks
is there any way that html element file
<input name="file1" type="file" style="width:300px">
only accept PDF files and when we browse its only show PDF files...
Thanks
Not really. See http://stackoverflow.com/questions/181214/file-input-accept-attribute-is-it-useful/181291#181291 .
Not with the HTML file control, no. A flash file uploader can do that for you though. You could use some client-side code to check for the PDF extension after they select, but you cannot directly control what they can select.
No way to do that other than validate file extension with JavaScript when input path is populated by the file picker. To implement anything fancier you need to write your own component for whichever browser you want (activeX or XUL)
There's an "accept" attribute in HTML4.01 but I'm not aware of any browser supporting it - e.g. accept="image/gif,image/jpeg
- so it's a neat but impractical spec
It can be useful to prevent the distracted user to make an involuntary bad choice, but in any case, you have to do the check on the server side anyway.
The best way is to be clear in the upload page. After that, if the user stupidly upload a big file with the wrong type, that's their loss of time, no?