Hi, I'm working on a small CMS with an image upload script, and everything is working great up until pulling the image path into the database.
(I'm using PHP 4+ and mySQL)
I've got the image uploading into the correct folder on the server, but now I need to feed the name of the file to the database so that I can pull up the image later.
Here's the code I have so far:
if ($_FILES['imagefile']['type'] == "image/gif") {
copy ($FILES['imagefile']['tmp_name'], "art/".$FILES['imagefile']['name']) or die ("Could not copy");
echo "";
echo "Name: ".$FILES['imagefile']['name']."";
echo "Size: ".$FILES['imagefile']['size']."";
echo "Type: ".$_FILES['imagefile']['type']."";
echo "Copy done...";
}
else {
echo "";
echo "Could not copy, submit GIF (".$_FILES['imagefile']['name'].")";
}
// The above code moves the file into the correct folder on the server, and it works great
// now I need to place the name of the file into the "image" field in my DB:
// I've tried transferring the name of the file to the variable "$new_image", but I guess I just don't know how.
$sql = "INSERT INTO CONTENT (title,subtitle,author,content,links,image) VALUES ('$title','$subtitle','$author','$content','$links','$new_image')";
$result = mysql_query($sql);
printf ("Article <b>\"%s\"</b> was ADDED<br><br>", $title);
// Thanks!