|
-
November 10th, 2006, 04:51 AM
#1
<inpu type="file">
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
-
November 10th, 2006, 08:13 AM
#2
Re: <inpu type="file">
 Originally Posted by elektroman
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
HTML Code:
<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
-
November 11th, 2006, 03:41 PM
#3
Re: <inpu type="file">
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 Code:
<?php
$ext = strtolower(substr(strrchr($file, "."), 1));
if($ext = "doc" || $ext = "xls"){
// upload
}
else{
echo "Invalid file type.";
}
?>
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|