Hello
How to upload an image into mysql table
what could be the possible query I write it?
is it possible to bind the image variable??
upload image into mysql table through php
Moderator: General Moderators
Upload the image file as you would any other file, get the contents using file_get_contents(), and insert the data into a BLOB field.
It's not really a good way to store images though .. the overhead is much greater than just storing the filename in the database and saving the file into a directory somewhere.
Not sure what you mean by "is it possible to bind the image variable??".
It's not really a good way to store images though .. the overhead is much greater than just storing the filename in the database and saving the file into a directory somewhere.
Not sure what you mean by "is it possible to bind the image variable??".
what can be the possible query if I assume there are two fields(one field is image and the other field is to identify the image)
I checked the viewtopic.php?t=40543
but Im doing some thing like this
Get the uploaded image directly into mysql database through mysql query
when Im prinitng
Array ( [name] => Dscf0007.jpg [type] => image/jpeg [tmp_name] => /tmp/phpCweDQX [error] => 0 [size] => 42970 )
which one of this I assume to be the complete image
I checked the viewtopic.php?t=40543
but Im doing some thing like this
Get the uploaded image directly into mysql database through mysql query
when Im prinitng
Code: Select all
$lob_upload = $_FILES['lob_upload'];which one of this I assume to be the complete image
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
i don't know if the file exists on the server yet when its just in $_FILE but you should seriously reconsider saving a image to a database. if you are still all about it, just do the actual upload to the server, then file_get_contents the location of the uploaded file, then insert that into the database (remember the field has to be type BLOB) then unlink() the uploaded file. very inefficient but thats the only way i know of doing it.
Code: Select all
$image = file_get_contents($_FILES['lob_upload']['tmp_name']);