Jump to content

Archived

This topic is now archived and is closed to further replies.

warnockm

storing Word and PDFs as BLOBs

Recommended Posts

Hi, i'm having some trouble storing and recovering Word/.doc and PDF files as blobs. i'm loading the content from an uploaded file and storing it to a BLOB. i realized i needed addslashes() to make it store properly, however, stripslashes() on the download strips slashes that were in the original file, rendering it unopenable. Am i missing something?

Thanks,

Share this post


Link to post
Share on other sites
That's seems impossible -- these functions are each other's inverse, such that x = stripslashes(addslashes(x)). There must be something else going on -- are you sure magic quotes aren't on?

Share this post


Link to post
Share on other sites
[!--quoteo(post=367087:date=Apr 20 2006, 11:16 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 20 2006, 11:16 PM) [snapback]367087[/snapback][/div][div class=\'quotemain\'][!--quotec--]
That's seems impossible -- these functions are each other's inverse, such that x = stripslashes(addslashes(x)). There must be something else going on -- are you sure magic quotes aren't on?
[/quote]

Thanks for the reply. I checked and magic quotes are OFF. When i uploaded a file and downloaded and compared the original to the downlaoded. There are slashes in the original that are being removed. Isn't it possible that there are slashes not added by addslashes() that are removed by strip slashes?

Share this post


Link to post
Share on other sites
Try not using [a href=\"http://www.php.net/stripslashes\" target=\"_blank\"]stripslashes[/a] when retrieving the information from the database.

When you use addslashes you're only escaping characters that would be misinterpreted by MYSQL had you not. The end result is that only your original data is stored, not the slashes that were used to escape the data. You should only need to worry about stripping slashes from the data retrieved if [a href=\"http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime\" target=\"_blank\"]magic_quotes_runtime[/a] is on.

Share this post


Link to post
Share on other sites
[!--quoteo(post=367984:date=Apr 24 2006, 10:24 AM:name=shoz)--][div class=\'quotetop\']QUOTE(shoz @ Apr 24 2006, 10:24 AM) [snapback]367984[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Try not using [a href=\"http://www.php.net/stripslashes\" target=\"_blank\"]stripslashes[/a] when retrieving the information from the database.

When you use addslashes you're only escaping characters that would be misinterpreted by MYSQL had you not. The end result is that only your original data is stored, not the slashes that were used to escape the data. You should only need to worry about stripping slashes from the data retrieved if [a href=\"http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime\" target=\"_blank\"]magic_quotes_runtime[/a] is on.
[/quote]

yeah, that fixed it. But my question is, why? I don't have Magic quotes on in my php.ini

Share this post


Link to post
Share on other sites
First let me point out that [a href=\"http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime\" target=\"_blank\"]magic_quotes_runtime[/a] and [a href=\"http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc\" target=\"_blank\"]magic_quotes_gpc[/a] are different things.

As far as your question goes. The fact that magic_quotes_runtime is [b]not on[/b], is the reason why you don't need to stripslashes from the database retrieved data.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.