Welcome to WebmasterWorld Guest from 22.214.171.124
1/ Hardest method. Save the image in the database as type BLOB. Load the image file either from the upload, as normal, or from another disc location. Read the file into a variable using file_get_contents() or similar. You need to pay careful attention to the type of the file, either using $_FILE[whatever][type] which is e.g. "Image/gif".
Now, when you output the file, send a header("Content-type: Image/gif"); and then output the contents of the BLOB. It should work fine.
2/ Easier method. Just upload the file, save it to disk, but store the filename in the database.
3/ Easy, but not easiest method. Upload the file, save it to disk using a unique identifier as filename (i.e. the auto_increment column from mysql), then save the original filename in the mysql database.
The mysql people themselves recommend storing as a file and not as a blob in the db.
The problem is that users are going to be uploading images so is there a simple way to rename an image as it is uploaded into the folder on the server...maybe with an auto-increment number?
Almost there...thanks again!
I really apologise for being a dunce here but how do I save the file to disk using the the auto_increment column from mysql, then save the original filename in the mysql database.
I have searched around but cant find any info.
Note: You don't have to do *both*. Either get the id from the db, and always name your files $id.gif, or else save the name of the file in the db. Quite obviously, these are mutually exclusive techniques.