How Do u insert images in to Mysql database using this front end can somebody help me .
Is there a simple query which i can write where i can design a field for images and then what should the field type be ????(blob , text ????)
If binary how should i spoecify the field type as binary ,
??
Please help me
Thanks
--Harry
Inserting Images in MySQL
Your column (field) type should be one of the BLOB types. The various BLOB types vary in length.
See the mySQL manual for size restrictions:
http://www.mysql.com/doc/n/o/node_181.html
A BLOB field is binary by definition.
You can use an input tag with the type attribute set to file to upload a file via an html form. You can then open the file with fopen() in php. Use fread() to store the contents of the file in a variable and the addslashes() function to escape anything that might look like quotes in the file contents. Then use mysql_query() to send an INSERT query to mysql.
Generic Example:
$file_ptr = fopen($tmp_file_name,"r");
/ open your binary data for reading /
$file_contents = fread($file_ptr, filesize($tmp_file_name));
/ read in your data /
$file_contents = addslashes($file_contents);
/ escape your data for your sql query /
$mysql_query = "INSERT INTO [database.table] (\"[binaryfield]\") values (\"".$file_contents."\")";
/ do the INSERT. note - quotes are very important!!! /
Hope this helps...
Matt
[deleted]
Or read this article: