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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.