I've got a small problem. I'm trying to save image, and retrive it from a database table. I've got a table with BLOB column, where images are saved.
Here is the script:
INSERT INTO male_users (image) VALUES ('$image')
And everything works fine, image is saved in database. But then i try to retrive it by this code:
echo " Image: <img src='" . $row["image"]. "' />"
But image is not displaying there is only an image name, for example: "DSC0123.jpg", and thats all.
Thanks for help in advance! Best regards
It's not best practice to store an image in a database, as the database will get very big, and slow. It's better if you just store the path to the image file in the server.
You can upload images and save them in your server very easily with PHP. Since it's out of the scope of this question I'll leave you some tutorials:
https://davidwalsh.name/basic-file-uploading-php http://www.w3schools.com/php/php_file_upload.asp
And to answer your actual question, you're not saving the image, but the image name, you should use $_FILE
and not $_POST
when we're dealing with file uploads in PHP.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments