"SAVARD, Marc" wrote:
> I am trying to build a database in which I would like to store binary files.
> I know I have to use BLOB fields but am facing problems with the insert
> method.
> The problem is I have to handle characters like ", ' or \ that "disturb"
> PHP.
> One method would be to base64_encode the files before storing them in my
> BLOB fields.
> The trouble is this would expand the file by 33%.
>
> Isn't the a way like opening a sort of pipe directly to the record I am
> creating/updating to drop the file in it ?
>
> I know this is quiet a common problem; I guess many many many people have
> faced this problem but can't find any answer anywhere... please help me not
> using base64...
Funny thing, you are asking this on a Perl related mailing list ... :-)
With DBI, you had two options:
- Use $dbh->quote() for quoting a string, then feed it into MySQL.
- Use placeholders, as in INSERT INTO foo VALUES (?, ?, ...)
I have tried hard to get the same thing working with PHP, my personal
opinion is that PHP isn't working well with NUL (binary 0) characters.
I may be wrong here, though. Reprogramming $dbh->quote() in C and
create a PHP function mysql_quote() should be quite easy, but I have
no idea how to represent a string with NUL's in PHP.
I suggest you better use HTML::EP, HTML::EmbPerl, HTML::Mason,
Apache::ASP
or something similar.
Sorry,
Jochen