Jump to content

just found this


jeppers

Recommended Posts

<?php

// force to download a file
// ex, ( [url=http://localhost/php/download.php?file=C:/Apache]http://localhost/php/download.php?file=C:/Apache[/url] Group/Apache2/hongkong.php )
// hope this can save your time :-)

$file = $_REQUEST['file'];

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=".basename($file));

header( "Content-Description: File Transfer");
@readfile($file);

?>

 

can any one help i need to direct this code to a file which i want to download any ideas

 

at the moment it just downloads a blank document and i am not sure on how to change the outcome

Link to comment
https://forums.phpfreaks.com/topic/60590-just-found-this/
Share on other sites

I don't know if this will help you at all, but this is what I use:

<?php

    if (isset($_GET['filename'])){

        header('Content-Type: application/octet-stream');
        // what the file will be called
        header("Content-Disposition: attachment; filename=".$_GET['filename'].";");
        // It the file will be named when it is down loaded
        readfile(str_replace('|||||',' ',$_GET['filename']));
    
    }else{
    
    }

?>

Link to comment
https://forums.phpfreaks.com/topic/60590-just-found-this/#findComment-301413
Share on other sites

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.