Reputation: 1045
Hi I'm trying to add my image name to my database, I have a page that adds a file to my server in a folder called uploads but I then want to be able to on creation of a news article, get the image name that I've uploaded and add that to the relevant article in a variable called $Image_Name so I can show the relevant image to the article.
is there some code I can add to my form to search browse the image and add the name to a field then when I do my insert query on the following page just get that value like I do for all my text fields.
Any help would be great as I still very new to php and mysql.
thanks.
Upvotes: 1
Views: 4200
Reputation: 609
Maybe this will help you:
$image = $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"],"../upload/$image");
$query = "INSERT INTO images VALUES('','$image')";
Upvotes: 2