PHP/MySQL storing/viewing images?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
julien.duponte
Forum Newbie
Posts: 2
Joined: Thu Apr 14, 2011 1:25 pm

PHP/MySQL storing/viewing images?

Post by julien.duponte »

Hello,
I've been given a recent project for a website and am having a difficult time wrapping my head around some of the MySQL processes. I haven't used MySQL much, so I apologize ahead of time for any ignorance.

I believe that I am going to be actually storing the images inside MySQL. Here is my confusion, I think. And, forgive, I have been pouring over PHP/MySQL tutorials, but they always address only one or the other, with regard to forms and upload pages. I would like to create an upload/edit page, that allows my customer to basically add an entry (almost like a news feed, I guess), as well as upload an image. I want the rows to all be tabled down the page, like they are here:

http://www.nwtillers.com/equipment.html

Can I upload a file, INSERT data (or UPDATE, if I create an edit option), all with the same SUBMIT button, then have it dynamically rendered on, say 'equipment.php'.

So far, how I am assuming that this will work, is that I'll have an update.php file, with the actual form,
that sends to a process.php file, that uploads/inserts the data into the database and forwards to an updated.php form, that just prints out if the upload/update was successful.
I am assuming/hoping, that then equipment.php will have been updating to look as it does now, but with this new feature.

I have some code that I'm working on, but I'm still having trouble wrapping my brain around it. I'm not wanting anyone to do my work, more just wanting to know if I'm just looking at the wrong tutorials/missing some functions/or entirely missing some steps. Thanks for the responses!
Matthew
divedj
Forum Commoner
Posts: 47
Joined: Wed Dec 29, 2010 4:32 am
Location: Malta

Re: PHP/MySQL storing/viewing images?

Post by divedj »

Images are usually just uploaded in a folder with a unique file name.

you store your data concerning the image including an id and where to find the file again when needed from your page displaying your image or the page updating the data.

I am using an upload folder where my upload script stores the image uploaded. If you have different users or various site admins uploading you could define a different upload folder for each user.
From there comes a action script asking what to do with the image - add to database move it to it's final location making sure the file name is unique.

Hope I could straighten up yout thoughts a bit.
Post Reply