aim25 Posted June 26, 2007 Share Posted June 26, 2007 Well i was just wondering if there was any way to actually upload the image to the database, and opposed to putting the image somewhere else and recording its url and other info in a table. Link to comment https://forums.phpfreaks.com/topic/57277-solved-can-you-upload-images-directly-to-mysql/ Share on other sites More sharing options...
Wildbug Posted June 26, 2007 Share Posted June 26, 2007 Sure, you can put the data in a PHP variable and INSERT it into a MySQL BLOB column as you would normally. Use mysql_real_escape_string() to escape anything that would break the query. $image = file_get_contents('image location...'); // or from $_FILES or whatever mysql_query(sprintf('INSERT INTO images (image) VALUES ("%s")',mysql_real_escape_string($image)); That simple example should work. Link to comment https://forums.phpfreaks.com/topic/57277-solved-can-you-upload-images-directly-to-mysql/#findComment-283119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.