samoht Posted June 22, 2009 Share Posted June 22, 2009 Hello all I have a download.php file with this code: <?php $Login = $_REQUEST['login']; switch($_REQUEST['file']) { case 'SurgimapSetup.exe' : $myFile = 'SurgimapSetup.exe'; $filelocation = 'nsis/' . $Login . '/' . $myFile; header("Content-Length: " . filesize($filelocation)); header("Content-type: application/exe"); header("Content-Disposition: inline; filename=\"" . $myFile . "\";"); break; default: break; } ?> and I provide a simple link as such: <a href = "surgimap_api/download.php?login='.$name.'&file=SurgimapSetup.exe" > for some reason it says that I am downloading "SurgimapSetup.exe" - but the file size is 0?? I know the correct file exists... what am I doing wrong? thanks, Link to comment https://forums.phpfreaks.com/topic/163300-solved-problem-with-download-link/ Share on other sites More sharing options...
volatileboy Posted June 22, 2009 Share Posted June 22, 2009 have you tried using an absolute path to the file, ie: home/user/public_html/folder/etc/etc/file.exe Link to comment https://forums.phpfreaks.com/topic/163300-solved-problem-with-download-link/#findComment-861543 Share on other sites More sharing options...
flyhoney Posted June 22, 2009 Share Posted June 22, 2009 you need to add readfile($filelocation); <?php $Login = $_REQUEST['login']; switch($_REQUEST['file']) { case 'SurgimapSetup.exe' : $myFile = 'SurgimapSetup.exe'; $filelocation = 'nsis/' . $Login . '/' . $myFile; header("Content-Length: " . filesize($filelocation)); header("Content-type: application/exe"); header("Content-Disposition: inline; filename=\"" . $myFile . "\";"); readfile($fileLocation); break; default: break; } Link to comment https://forums.phpfreaks.com/topic/163300-solved-problem-with-download-link/#findComment-861544 Share on other sites More sharing options...
samoht Posted June 22, 2009 Author Share Posted June 22, 2009 thanks flyhoney! That did the trick Link to comment https://forums.phpfreaks.com/topic/163300-solved-problem-with-download-link/#findComment-861588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.