Jump to content

need help badly with download script


yobo

Recommended Posts

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

<?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


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.