Hi,
I know this is a bit of a stupid question but I just need some syntax help.
What would I set the ACCEPT field to if I want the file field to upload only PDFs and DOCs.
Thanks,
--SL
If i'm not mistaken, the file types are
application/pdf application/msword
So you'd run an if using $_FILES['userfile']['type'] (http://www.php.net/manual/en/features.file-upload.php)
So something like
// PDF if($_FILES['userfile']['type'] == 'application/pdf') { echo "File is PDF"; } // Word Document if($_FILES['userfile']['type'] == 'application/msword') { echo "File is Word Document"; }
Cgraz
Thanks for your reply. Is there anyway that I could force this client side.
Would something like this work?
<INPUT name=file type=file id="file" maxLength=128 ACCEPT="application/pdf, application/msword">
Thanks again,
When they click browse, you may be able to allow them to only browse for a certain filetype. I think I've seen this done before, but I'm not sure how to do it. I'd search the net and see what you can find. I'll let you know if I run across anything.
I could figure it out for one but not two...
You got it to work with one? I played around with it and didn't even get it to only say that specific filetype. I did a search on htmlgoodies, and according to him, the ALLOW attribute is worthless (http://www.htmlgoodies.com/attachp2.html). You'll have better luck verifying it server-side.
Well, thanks for trying. Appreciated.
I don't know about that article though. Allow is not part of the input tag so it definately won't work. It is supposed to be accept.
http://www.htmlhelp.com/reference/html40/forms/input.html
regexp