nw Posted August 25, 2008 Share Posted August 25, 2008 I am trying to learn how to do basic stuff with PHP and MySQL. I am trying to create a simple web database that uses photos and other graphic images. I would like to store images in normal files with the filename being recorded in the database, but I don’t know how to do this. Can someone provide me with the basic information and/or code so that I can put the filenames and information about the images into the database and then link them with the actual image itself so that they will display on the webpage. Thanks, Neil Link to comment https://forums.phpfreaks.com/topic/121171-images-in-mysql/ Share on other sites More sharing options...
ratcateme Posted August 25, 2008 Share Posted August 25, 2008 you need to do a simple file upload. then add a line to a database like this $file_name = $_FILES['image']['name']; $ext = $ext = substr($name,strrpos($name,".")+1); $result = mysql_query("INSERT INTO `images` (`file_name`,`uploaded_by`,`time`) VALUES('{$file_name}','{$username}',NOW());",$con); $id = mysql_insert_id($result); move_uploaded_file($_FILES['image']['tmp_name'],"images/{$id}.{$ext}"); then when you display the image you can say it is called the file_name but link them to the "id.ext" Scott. Link to comment https://forums.phpfreaks.com/topic/121171-images-in-mysql/#findComment-624701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.