Click to See Complete Forum and Search --> : <inpu type="file">
elektroman
November 10th, 2006, 03:51 AM
Hi guys
I want to ask you a very simple question
Is there a property for the <input type="file"> that allow to set only an extension (for example .doc or .xls) that will appear in the box of the files called by the button browse of the <input type="file">?
Thanks in advance
Yanco
November 10th, 2006, 07:13 AM
Hi guys
I want to ask you a very simple question
Is there a property for the <input type="file"> that allow to set only an extension (for example .doc or .xls) that will appear in the box of the files called by the button browse of the <input type="file">?
Thanks in advance
Hi the documentation says it could be done via ACCEPT parameter
<input type="file" value="GetTime" accept="image/gif,image/jpeg" />
But obviously browsers do not support this feature (yet).
If you want to learn more you could try http://www.cs.tut.fi/~jkorpela/forms/file.html
ther is also a workaround script for this problem you might find useful..
Good luck :)
Yanco
PeejAvery
November 11th, 2006, 02:41 PM
I would suggest doing this on the server-side rather than the client-side. You can just read the file extension and accept or reject it.
Here is a PHP example.
<?php
$ext = strtolower(substr(strrchr($file, "."), 1));
if($ext = "doc" || $ext = "xls"){
// upload
}
else{
echo "Invalid file type.";
}
?>
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.