Jump to content

[SOLVED] Strange download problems.


WorldDrknss

Recommended Posts

I am having a strange download problem. When click on the download link the first time it downloads the correct file. When it's click again it wants to download the module.php file. When it's click for the third time it will download the correct file and it repeats this process. Even though a user should only need to click on the download link once, I would like to get this fixed.

 

The Form:

<form action='/modules.php?name=generators&file=virtualhost&action=download' method='post'><input type='hidden' name='httpdv' value='".htmlentities($coninfo, ENT_QUOTES)."'><input type='submit' name='go' value='Download VirtualHost'></form>

 

The Download Process:

$httpdv = html_entity_decode(stripslashes($httpdv));
$filesize = strlen($httpdv);
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="httpd-vhosts"'); //This should work for IE & Opera
header('Content-Type: application/octet-stream; name="httpd-vhosts"'); //This should work for the rest
header('Content-Disposition: attachment; filename="httpd-vhosts.conf"');
header("Content-length: $filesize");
echo($httpdv);

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/40482-solved-strange-download-problems/
Share on other sites

The script checks to make sure that $httpdv is not empty before starting downloading:

if(isset($go)){
switch ($action){
	case download:
	if($httpdv !=""){
		$httpdv = html_entity_decode(stripslashes($httpdv));
		$filesize = strlen($httpdv);
		header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
		header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
		header('Content-Transfer-Encoding: none');
		header('Content-Type: application/octetstream; name="httpd-vhosts"'); //This should work for IE & Opera
		header('Content-Type: application/octet-stream; name="httpd-vhosts"'); //This should work for the rest
		header('Content-Disposition: attachment; filename="httpd-vhosts.conf"');
		header("Content-length: $filesize");
		echo($httpdv);
	} else {
		header("Location: ../../modules.php?name=guides");
	}
}
}

 

I will try php empty function and see how it reacts

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.