WorldDrknss Posted February 28, 2007 Share Posted February 28, 2007 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 More sharing options...
monk.e.boy Posted February 28, 2007 Share Posted February 28, 2007 I think this may be that $httpdv is empty sometimes. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/40482-solved-strange-download-problems/#findComment-195941 Share on other sites More sharing options...
WorldDrknss Posted February 28, 2007 Author Share Posted February 28, 2007 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 Link to comment https://forums.phpfreaks.com/topic/40482-solved-strange-download-problems/#findComment-196298 Share on other sites More sharing options...
WorldDrknss Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks monk.e.boy. That little bit of information was enough to help me solve the problem. Link to comment https://forums.phpfreaks.com/topic/40482-solved-strange-download-problems/#findComment-196304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.