uploading only pdf's

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 26
Joined: Sat Jun 25, 2011 4:40 am

uploading only pdf's

Postby ravi951 » Fri Jul 08, 2011 11:29 pm

Hi all,
i want a php program to upload only pdf files other files it should not take.i have tried below code but it is accepting all files..

if($_POST[upload] =="1")
echo "uploaded";
else "it is not a pdf";
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="upload" value="1">
<input type="file" name="file">
<input type="submit" value="upload">
Kindly give me a program.....

New php-forum User
New php-forum User
Posts: 7
Joined: Tue Oct 11, 2011 6:07 pm

Re: uploading only pdf's

Postby isomorph » Mon Oct 17, 2011 8:05 pm

For those running into this issue in the future (original has been resolved), you can find a discussion here that should lead you to an appropriate answer:


New php-forum User
New php-forum User
Posts: 10
Joined: Sun Oct 23, 2011 12:38 pm

Re: uploading only pdf's

Postby yassinebelkaid87 » Sun Oct 23, 2011 2:33 pm

you have to change if($_FILES['file']['type']="application/pdf") to if($_FILES['file']['type']=="application/pdf") and add a new condition if (isset($_POST[upload])).

Good Luck.

Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest