droidus Posted August 24, 2011 Share Posted August 24, 2011 i am trying to let users download images, but it seems to only be working for only a png image. i've tried .txt, word, and mp3. here is my code for getting the path of the file: // get full file path (including subfolders) $file_path = $fileName; find_file(BASE_DIR, $fname, $file_path); if (!is_file($file_path)) { die("File does not exist. Make sure you specified correct file name."); } these other files that i am getting, are in the same folder as the image. the error that i am getting, is "File does not exist. Make sure you specified correct file name." here are the allowed extensions of the files: $allowed_ext = array ( // archives 'zip' => 'application/zip', // documents 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // executables 'exe' => 'application/octet-stream', // images 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', // audio 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', // video 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo' ); Quote Link to comment https://forums.phpfreaks.com/topic/245600-download-issues/ Share on other sites More sharing options...
requinix Posted August 24, 2011 Share Posted August 24, 2011 Those small samplings of code aren't enough. Post the whole thing. Quote Link to comment https://forums.phpfreaks.com/topic/245600-download-issues/#findComment-1261454 Share on other sites More sharing options...
droidus Posted August 25, 2011 Author Share Posted August 25, 2011 http://pastebin.com/SPgMz2v2 Quote Link to comment https://forums.phpfreaks.com/topic/245600-download-issues/#findComment-1261682 Share on other sites More sharing options...
requinix Posted August 25, 2011 Share Posted August 25, 2011 Line 119 should be $file_path = null; Separately, 1. Lines 108-111 should be before the while loop, not inside it. 2. You should have a closedir to complement the opendir(). 3. Line 150 should use "application/octet-stream". Quote Link to comment https://forums.phpfreaks.com/topic/245600-download-issues/#findComment-1261923 Share on other sites More sharing options...
droidus Posted August 26, 2011 Author Share Posted August 26, 2011 here is my code now: http://pastebin.com/W4HqyTn9 no for the image, i get the error message: "File does not exist. Make sure you specified correct file name." Quote Link to comment https://forums.phpfreaks.com/topic/245600-download-issues/#findComment-1262100 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.