Jump to content

Having Trouble Uploading a file to Database...(mysql) Easy Question


idontknowphp

Recommended Posts

I am very new to php and am trying to create a simple application that uploads a PDF file to a database. I have one field for the Volume Number and on file field for the PDF to be uploaded. My issue is i can't get the PDF to upload or insert the name of the pdf (eg volume1.pdf) into the data base.

 

I would also like to point out that I know i have a low post count, but i only seek help when i truly need it and have exhausted all other resources...

 

Here is what i have, please go easy on me this is my first round at php:

<?php
if(isset($_POST['submit'])){
$vol_num = $_POST['vol_num'];
$pdf = $_FILES['pdf']['name'];
	$path = '../pdf/'.$_FILES['pdf']['name'];
	move_uploaded_file($_FILES["pdf"]["tmp_name"], $path);
        mysql_query("INSERT INTO volumes set vol_num='$vol_num', vol_link='$pdf'") or die (mysql_error());
	echo "<script>location.href='add_volume.php'</script>";
}
?>

 

what am i doing wrong here?

 

Thanks in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.