warnockm Posted April 20, 2006 Share Posted April 20, 2006 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, Quote Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/ Share on other sites More sharing options...
fenway Posted April 21, 2006 Share Posted April 21, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/#findComment-29231 Share on other sites More sharing options...
warnockm Posted April 24, 2006 Author Share Posted April 24, 2006 [!--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? Quote Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/#findComment-30079 Share on other sites More sharing options...
shoz Posted April 24, 2006 Share Posted April 24, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/#findComment-30107 Share on other sites More sharing options...
warnockm Posted April 24, 2006 Author Share Posted April 24, 2006 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/#findComment-30128 Share on other sites More sharing options...
shoz Posted April 24, 2006 Share Posted April 24, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/7983-storing-word-and-pdfs-as-blobs/#findComment-30140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.