uploading only pdf's

This is where you share YOUR scripts with others

Moderators: egami, macek, gesf

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

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

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

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.

Post Reply