Subject | Re: [firebird-support] how to insert image blob in Firebird in PHP and ADODB |
---|---|
Author | Helen Borrie |
Post date | 2014-01-22T06:43:55Z |
At 07:30 a.m. 22/01/2014, g80rock@... wrote:
Helen Borrie, Support Consultant, IBPhoenix (Pacific)
Author of "The Firebird Book" and "The Firebird Book Second Edition"
http://www.firebird-books.net
__________________________________________________________________
>I have done it in Delphi, but now i have the same problem finding how to do it in PHP.The reason for that error is that BLOB sub_type -1 would not exist unless you had written and declared a custom BLOB filter for that sub_type.
>
>I searched two days.
>
>I need to store image in the database and not as a file on the server.
>i have set blob field to subtype -1.
>
>i first do base64_encode for the file in PHP and then try to insert it in SQL.
>But get error:
>General error: -413 filter not found to convert type 1 to type -1
>The code is:Maybe for PHP (I don't know about that) but Firebird has no knowledge of what is inside a non-text BLOB. Normally you would just store the image contents as a BINARY BLOB (sub_type 0).
> $imgSrc='testimage.jpg');
> $img_src = $imgSrc;
> $imgbinary = fread(fopen($img_src, "r"), filesize($img_src));
>
> $img_str = base64_encode($imgbinary);
> $sql="insert into info (ID,LOGO) values('1','$img_str')";
>
>I think it has to do something with the header type. as JPG or something.
>this only gives error.Then my advice is to ask on the Firebird-PHP list - someone there will surely have done this.
>and i just can't find any examples on net.
>is there anyone that have an example to how to do it in PHP?
>
>i really need help on this.
Helen Borrie, Support Consultant, IBPhoenix (Pacific)
Author of "The Firebird Book" and "The Firebird Book Second Edition"
http://www.firebird-books.net
__________________________________________________________________