dmschenk Posted November 25, 2007 Share Posted November 25, 2007 Is there a way that I can upload an image to a directory on my website and have the image name recorded into a database field without having to create a separate field for that name? Dave Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 25, 2007 Share Posted November 25, 2007 Then how will you know the name? what you are asking makes no sense Quote Link to comment Share on other sites More sharing options...
dmschenk Posted November 26, 2007 Author Share Posted November 26, 2007 Lemme rephrase it. I would like to upload a photo (Example.. image001.jpg) to a directory on my website with a file input field (this much I can do). I would like to take that name (image001.jpg) from the input field and stick into a database without having to retype the name into a separate field. So in one move I would like to upload a file "and" populate a db field. I'm just trying to eliminate places where mistakes can happen. Dave Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 26, 2007 Share Posted November 26, 2007 well uploaded images should never have the same name as they were updated this is just bad practice as people could upload a file with the same name and you have a bigger issue. Upload the file, rename it to some linear based system like USERID_ImageID and then store that, I don't see what the issue is honestly its just a query Quote Link to comment Share on other sites More sharing options...
dmschenk Posted November 27, 2007 Author Share Posted November 27, 2007 I'm not exactly sure where you are going with this. I'm just looking for an efficient way to get the database to recognize that something has been stored online. I can do it with separate fields... I just want to know if and how it can be done with just one field and streamline the process. Dave Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted November 27, 2007 Share Posted November 27, 2007 when you upload the image you should check that a file with the same name is not in the same location - if it is you shoudl rename the image that is being uploaded. but back to your specific question - the information about the uploaded file is stored in the $_FILES supre global - you can grab the name of the original from there and add it where ever you like in your database. Quote Link to comment Share on other sites More sharing options...
dmschenk Posted November 29, 2007 Author Share Posted November 29, 2007 Thanks, I've got it working now. The form checks names as files are uploaded and renames the new file if there is a duplicate name in the directory then drops that file name into the db so it can be used. Dave Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.