【发布时间】:2013-11-05 07:55:40
【问题描述】:
从 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 类型。
如何将 PHP 中的图像正确存储为 BLOB?
PS:不愿意采用文件系统存储。
【问题讨论】:
-
你遇到了什么问题?确保您的表满足数据类型存储要求:docs.oracle.com/cd/E17952_01/refman-5.6-en/…
-
嗨,是的,图像字段是 BLOB 类型,确实我使用的是 MySQL
-
它是BLOB,但是,什么类型的BLOB?您不能在 BLOB 类型字段中存储大于 64KB 的数据。你确定你的桌子符合要求吗?再说一次,你到底遇到了什么问题?有任何错误信息吗?
-
我将 BLOB 类型更改为
longblob,对于错误消息,我应该在哪里看到?哪个文件,我正在使用 MAMP。谢谢。 -
更改为 $result = mysql_query($sqlinsertimages) OR die(mysql_error());