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 Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/ Share on other sites More sharing options...
robert_gsfame Posted December 4, 2009 Author Share Posted December 4, 2009 i need someone helps :'( Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971035 Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2009 Share Posted December 4, 2009 whats your code for downloading the file ? Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971040 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 Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971043 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 ? Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971049 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! Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971053 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 . '"'); Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971057 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 !! Link to comment https://forums.phpfreaks.com/topic/183940-download-simple-problem/#findComment-971063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.