robert_gsfame Posted December 4, 2009 Share Posted December 4, 2009 user has uploaded their document named = "my document.doc" and stored inside the database once downloaded, i get this "my.doc" and ignoring the document as there is some little space between my and document. Can i still get "my document.doc"?? i've tried nl2br but still didn't work Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted December 4, 2009 Author Share Posted December 4, 2009 i need someone helps :'( Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2009 Share Posted December 4, 2009 whats your code for downloading the file ? Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted December 4, 2009 Author Share Posted December 4, 2009 im trying both downloading and showing the image using <img src> below is the code for downloading: assume myimage table contains the file $fileName=$array['myimage']; $mimeType = 'image/jpeg'; header('content-disposition: attachment; filename=' . $fileName); header('content-type: ' . $mimeType); header('content-length: ' . filesize("folder/{$fileName}")); readfile("folder/{$fileName}"); besides i also tried to show the image using <img src=folder/$fileName> but also didn't appear Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2009 Share Posted December 4, 2009 does it store the name in the db as my.doc ? or the problem only happens while downloading ? Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted December 4, 2009 Author Share Posted December 4, 2009 okay i got the problem for showing the image as i can str_replace(" ","%20"); but then i tried to use it for the downloading and NOT WORKING there is no problem when storing the record into the table as it has been stored using the name of the file itself although it contains spaces! The problem occurs during the downloading as any character after space cannot be read! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2009 Share Posted December 4, 2009 Ah here you go this should work, change the code corresponding notice the quotes header('content-disposition: attachment; filename="' . $fileName . '"'); Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted December 4, 2009 Author Share Posted December 4, 2009 THX rajivgonsalves !!! NICE CODE!!!! quote really makes different!! THX so much !! Quote Link to comment 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.