Storing Images In MySQL
The Upload Form
The upload for is basically the same as for any file upload
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head><title>File Upload To Database</title></head> <body> <h3>Please Choose a File and click Submit</h3> <form enctype="multipart/form-data" action=" echo $_SERVER['PHP_SELF']; " method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> <input name="userfile" type="file" /> <input type="submit" value="Submit" /> </form> </body> </html>
It is important to use the
enctype="multipart/form-data" so that the browser uploads the binary data correctly.
No surprises here, although we do stress you have the hidden field for
MAX_FILE_SIZE. This can be handy for not allowing images that are too large to be uploaded. Remember also about the PHP