PHP Help
- Started
- Last post
- 3 Responses
- violent
hey everyone i was trying to find a tutorial for uploading an image and posting it to a database.
i tried a few different spots but most of them just deal with the regular uploading of images to a directory which i know, but i cant figure out how to upload the image and post it into a database.
any help would be greatly appreciated.
- Mick0
Not sure of exact code or anything but most sites that I know usually use some javascript to do what you mentioned, the javascript usually sending some form data to the database and asigning filename and whatever else to the DB.
- violent0
hmm i'm sure if i find just any tut that shows me how to do that i can work with it, but thats the hard part — finding one...
- kappa0
I'm sure you know to add:
enctype="multipart/form-data"
to your form tag, but just best mention it since that can give huge unnecessary headaches.BUT, if you know how to store it to a directory, then storing it to a DB should be even easier.
if you're using SQL, create a column with type BLOB and store the image there (BLOB is binary, just like the photo). to retrieve the image, just ust the row ID and print the proper headers (Header("Content-Type: image/jpeg");) before print() 'ing the image data.
PHP.net has some nifty user posts about file uploads.