从iOS应用程序到php脚本,我想将一组图像存储为BLOB类型:
$profile_images = $_REQUEST['profile_images_array'];//get the array of images
//loop the images and store them one by one
foreach($profile_images as $image){
$sqlinsertimages = "insert into profile_images (id_client,image) Values ('".$id."',mysql_real_escape_string('".$image."'))";
$result = mysql_query($sqlinsertimages);
} 如果去掉图像字段(即BLOB类型),插入就会很好,所以问题显然与表中的保存BLOB类型有关。
如何以BLOB的形式正确存储PHP中的图像?
PS:不愿采用文件系统存储。
发布于 2013-11-04 23:42:44
好的,我想工作终于完成了,我不知道在将映像保存到MySQL之前必须先将图像保存到服务器:
foreach($profile_images as $image){
//Get the file as a string before inserting it to table
$content = file_get_contents($image);
$content = mysql_real_escape_string($content);
$sqlinsertimages = "insert into profile_images (id_client,image) Values ('".$id."','".$content."')";
$result = mysql_query($sqlinsertimages);
} https://stackoverflow.com/questions/19777506
复制相似问题