Jump to content

storing Word and PDFs as BLOBs


warnockm

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,
Link to comment
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?
Link to comment
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.
Link to comment
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
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.