Jump to content

[SOLVED] problem with download link


samoht

Recommended Posts

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

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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.