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..
<?php
if($_FILES['file']['type']="application/pdf")
{
if($_POST[upload] =="1")
{
$to="uploads/".$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$to);
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.....
uploading only pdf's
Moderators: egami, macek, gesf
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:
viewtopic.php?f=2&t=13427
viewtopic.php?f=2&t=13427
-
- New php-forum User
- Posts: 10
- Joined: Sun Oct 23, 2011 12:38 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.
Good Luck.