RE: [PHP] mysql load_file retreival

From: Chris (chris_at_leftbrained.org)
Date: 12/20/03


To: "PHP List" <php-general@lists.php.net>
Date: Sat, 20 Dec 2003 14:55:21 -0800

Gald to hear it works now. Are you base64 encoding it for any particular
reason? Seems to me that it would waste a lot of db space as base64 encoding
adds quite a bit to the filesize.

Chris

-----Original Message-----
From: Larry Brown [mailto:larry.brown@dimensionnetworks.com]
Sent: Saturday, December 20, 2003 2:16 PM
To: Chris; PHP List
Subject: RE: [PHP] mysql load_file retreival

Thanks for the help. I went through a troubleshooting phase that started
with writing the raw data from the mysql client to disk. Checking the size
it was apparent that it was much too small. I tried running my script with
a smaller pdf and it worked. It turns out that blob has a max of 64k. A
tad small for general use for holding graphics. I changed to a mediumblob
which is either 12 or 16 meg, I'm not sure off the top of my head now but,
that is plenty for my needs. I did end up changing the behaviour of my
script though. Instead of writing to a file and using load_file, I recieved
the file on upload, base64 encoded it and stored it directly to the db.
Then on retrieval, unencoded and handed it off with content type, size,
name, and application information in the header. It works very nicely.

Thanks again...

Larry

-----Original Message-----
From: Chris [mailto:chris@leftbrained.org]
Sent: Saturday, December 20, 2003 3:49 PM
To: PHP List
Subject: RE: [PHP] mysql load_file retreival

Try looking at the data that's supposed to be outputing the pdf. Something
may be failing somewhere and you might see an error message. If you don't
see any error messages and are apparently seeing gthe pdf data, check for
whitespace outside php tags and any extraneous echo's or print's, that would
very likely cause the pdf to not be able to be read properly.

Chris

-----Original Message-----
From: Larry Brown [mailto:larry.brown@dimensionnetworks.com]
Sent: Saturday, December 20, 2003 10:36 AM
To: Chris; PHP List
Subject: RE: [PHP] mysql load_file retreival

Oops, my bad on the post. I am not sending echo header...just header(...

I thought, based on reading from mysql that it did escape certain
characters. I'll start looking at other possibilities...

-----Original Message-----
From: Chris [mailto:chris@leftbrained.org]
Sent: Saturday, December 20, 2003 1:24 PM
To: PHP List
Subject: RE: [PHP] mysql load_file retreival

LOAD_FILE() shouldn't be escaping the data. Are you actually calling : echo
header()? the header function should not be echoed.

header('Content-type: application/pdf');
echo result[0];

-----Original Message-----
From: Larry Brown [mailto:larry.brown@dimensionnetworks.com]
Sent: Saturday, December 20, 2003 9:29 AM
To: PHP List
Subject: [PHP] mysql load_file retreival

I have set up a script to recieve a pdf file and store it in a mysql db
using "update db set field=load_file('fileIncludingFile') where id=$id".
Afterwards I can see the file has been uploaded into the blob field
successfully and without errors. Now I want to get the file back out. I
set up a script with "select field from db where id=$id" and used
mysql_query followed by mysql_fetch_row and did echo header("Content-type:
application/pdf"); and then echo result[0]; where result was the row
fetched. I get the prompt to open with pdf but pdf fails. I have
magicquotes on but I understand that the load_file() function within mysql
does the escaping etc. How can I "un-escape" the data? The only thing I
saw on the mysql manual is on how to use load_file_infile/load_file_outfile
which does not apply to this. Can someone lend a hand here?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Relevant Pages

  • Re: Umfrage zur Fahrradnutzung - jetzt auch online
    ... als PDF macht, wo doch HTML, PHP, mySQL und Co. existieren. ...
    (de.rec.fahrrad)
  • RE: [PHP] mysql load_file retreival
    ... I was following the example given on the php site that someone was using to ... Subject: mysql load_file retreival ... a smaller pdf and it worked. ... PHP General Mailing List ...
    (php.general)
  • RE: [PHP] mysql load_file retreival
    ... Try looking at the data that's supposed to be outputing the pdf. ... may be failing somewhere and you might see an error message. ... Subject: [PHP] mysql load_file retreival ... based on reading from mysql that it did escape certain ...
    (php.general)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)