Hello to all,
Im looking to upload pdf files to a server, just not sure how to do it. Im assuming it works similar to uploading images. I have successfully built an image uploader. Could someone show me how to modify it for pdf files?
Heres my code
[code]
<form enctype=”multipart/form-data” action=”addblogphoto.php” method=”POST”>
<td><input type=”file” name=”photo” /></td>
</tr>
<tr>
<td><input type=”submit” value=”Upload” /></td>
</tr>
</form>
And the script
[code]
<?php
error_reporting (E_ALL ^ E_NOTICE);
//This is the directory where songs will be saved
$target = “”;
$target = $target . basename( $_FILES[‘photo’][‘name’]);
//This gets all the other information from the form
$photo=($_FILES[‘photo’][‘name’]);
// Connects to your Database
mysql_connect(“localhost”, “root”) or die(mysql_error()) ;
mysql_select_db(“test_blog”) or die(mysql_error()) ;
//Writes the information to the database
mysql_query(“INSERT INTO `photo`(blogphoto) VALUES (‘$photo’)”);
//Writes the image to the server
if(move_uploaded_file($_FILES[‘photo’][‘tmp_name’], $target))
{
//Tells you if its all ok
echo “The file “. basename( $_FILES[‘uploadedfile’][‘name’]). ” has been uploaded, and your information has been added to the directory”;
header(“location: index.php”);
}
else {
//Gives and error if its not
echo “Sorry, there was a problem uploading your file.”;
}
?>
ANy help would be greatly appreciated!