yobo Posted March 17, 2007 Share Posted March 17, 2007 hey all, i am making a site where people store mods that they have made for phpbb, and it uploads the files to the database ok i have created a category page so that user can browse mods by categorys and when they have found a mod they like they click view which is a link and it will open up that mods profile page, on that mods profile page is a link to download it that link looks like this http://127.0.0.1/phpbb3hacks/dload.php?hacksid=29 (the 29 is the mods unqiue id, ever mod has a uniuqe id) now when i cliick on that download link instead of asking me to download the mods zip file it asks me if i want to download the actural download page wich is dload.php anyways here is my download page code (dload.php) <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); if(isset($_GET['hacksid'])) { $hacksid = $_GET['hacksid']; $query = "SELECT hackname, mimetype, filedata FROM hacks WHERE hacksid = '$hacksid'"; $result = mysql_query($query) or die('Error, query failed'); list($hackname, $mimetype, $filedata) = mysql_fetch_array($result); header("Content-Disposition: attachment; filedata=$hackname"); header("Content-length: $filedata"); header("Content-type: $mimetype"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/43174-need-help-badly-with-download-script/ Share on other sites More sharing options...
per1os Posted March 18, 2007 Share Posted March 18, 2007 http://us3.php.net/manual/en/function.readfile.php Check the user comments. Link to comment https://forums.phpfreaks.com/topic/43174-need-help-badly-with-download-script/#findComment-209776 Share on other sites More sharing options...
yobo Posted March 18, 2007 Author Share Posted March 18, 2007 i can't seem to found my situation within those user comments, becuase those users who have posted are storing there uploads in a folder i am storing them in a database Link to comment https://forums.phpfreaks.com/topic/43174-need-help-badly-with-download-script/#findComment-209852 Share on other sites More sharing options...
shaunrigby Posted March 18, 2007 Share Posted March 18, 2007 <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); if(isset($_GET['hacksid'])) { $hacksid = $_GET['hacksid']; $query = "SELECT hackname, mimetype, filedata FROM hacks WHERE hacksid = '$hacksid'"; $result = mysql_query($query) or die('Error, query failed'); list($hackname, $mimetype, $filedata) = mysql_fetch_array($result); header("Content-Disposition: attachment; filedata=$hackname"); header("Content-length: $filedata"); header('Content-Type: application/force-download'); //Try this line header("Content-Transfer-Encoding: binary"); //And this Link to comment https://forums.phpfreaks.com/topic/43174-need-help-badly-with-download-script/#findComment-209886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.