BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 I've got a problem in this http headers, maybe in the filename or path I've tried alot but no joy this script is to get the filename from the database and set the path to it so it gets downloaded. getfile.php: <?php if(is_numeric($_GET['fid'])){ $dirs = new Directories($db['host'],$db['username'],$db['password'],$db['name']); $fileId = $_GET['fid']; $rows = $dirs->getFile($fileId); if (!is_array($rows)) { echo $row; } foreach ($rows as $files){ $file = urldecode($files['file_name']); } $file = urldecode($file); $file_size = filesize(realpath($file)); $file = urlencode(basename($file)); $file = basename($file); // $final_file = urlencode(USER_UPLOADS . "/" .$file); $final_file = $file; if (!is_file($final_file)) { echo $final_file; } header("Content-length: {$file_size}"); header("Content-disposition: attachment; filename= '$final_file'"); header("Content-type: image/jpg"); header("Content-Description: Project File"); } ?> What this script does? It downloads a file with the same name but, 0 bytes any kind of help will be so appreciated Thank you Quote Link to comment Share on other sites More sharing options...
Sakesaru Posted December 25, 2008 Share Posted December 25, 2008 Your code doesn't redirect the browser to the file, it just tells it that the file will be named blah, it's a blah type file, then after the headers are sent, it doesn't send any data. You need to open the file in question with fopen(), then echo() the contents of the file out to the browser. OR You need to actually redirect the browser to the actual file. Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Author Share Posted December 25, 2008 Thanks alot this had done the job perfectly 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.