Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Checking if file is .pdf
Old 08-06-2010, 10:48 PM Checking if file is .pdf
Skilled Talker

Posts: 83
Trades: 0
Hi,
I'm creating an upload section that limits users to upload the following file types:

.pdf
.zip
.rar
.doc
.jpeg
.gif

When getting the type for .pdf files, it comes up as:
application/force-download

and for .rar files it comes up as:
application/x-download

If I do a check that says:

if ($type=="application/force-download" || $type=="application/x-download")

then will users only be able to upload .PDF and .RAR files? I'm assuming these two types will allow other formats as well.

If this is the case, how can I check the extension of the file before the user is able to upload it. I was thinking of somehow capturing the last 3 letters of the filename, and then doing the check that way, except I'm not sure how to go about this. Any insight appreciated!
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-07-2010, 12:15 AM Re: Checking if file is .pdf
Average Talker

Posts: 25
Name: Stephen
Location: Arizona
Trades: 0
If you want to check before the user uploads, you might want to use javascript. Otherwise, validate against $_FILES.

http://www.w3schools.com/PHP/php_file_upload.asp
__________________

Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
GetGamesHere is offline
Reply With Quote
View Public Profile Visit GetGamesHere's homepage!
 
Old 08-07-2010, 01:16 PM Re: Checking if file is .pdf
phpdasan's Avatar
Experienced Talker

Posts: 37
Name: Karthick B
Trades: 0
Try this upload file

http://www.verot.net/php_class_upload.htm

The file provide allowed type, there you have the option to choose which file type to allow.
__________________
There is no secret ingredient.
phpdasan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Checking if file is .pdf
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34884 seconds with 12 queries