首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将图像(NSData)插入BLOB字段

问将图像(NSData)插入BLOB字段
EN

Stack Overflow用户
提问于 2013-11-04 21:29:39
回答 1查看 500关注 0票数 1

从iOS应用程序到php脚本,我想将一组图像存储为BLOB类型:

代码语言:javascript
复制
 $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:不愿采用文件系统存储。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-04 23:42:44

好的,我想工作终于完成了,我不知道在将映像保存到MySQL之前必须先将图像保存到服务器:

代码语言:javascript
复制
            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);
            }   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19777506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档