Storing Images in MySQL Revisited
In this article I showed you how to store images in MySQL. We began by
looking at MySQL's
blob data type, used for storing binary
Next I showed you how to create a file upload form, as well as how to process the file upload.
Next we created a script to send an image to the user's browser, including setting the correct HTTP headers.
Finally, we created a list of previously uploaded images so they can be viewed.
- MySQL Blob type: http://dev.mysql.com/doc/refman/5.1/en/blob.html
- Handling file uploads in PHP: http://www.php.net/manual/en/features.file-upload.post-method.php
- Upload error messages: http://www.php.net/manual/en/features.file-upload.errors.php
- PHP header() function: http://php.net/header
Download a PDF version of this article,
including the following bonus listing:
- Sending a thumbnail version (thumbnail.php)
- Put your PHP knowledge to the test with our online and iPad/iPhone quizzes
- View or post comments for this article
- Browse similar articles by tag: MySQL, PHP