1

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: ファイル システム ストレージを採用する気はありません。

4

1 に答える 1

0

わかりました、ようやくうまくいったと思いますが、イメージを 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);
            }   
于 2013-11-04T23:42:44.927 に答える