The whole index.php? = <Filename> .exe

I've never figured out how to do it. I want where I can enter my url followed by the file /index.php?=<a which is located on FTP> .exe. From there, I would be right on a page that has a download now button and maybe something like an ad.

Anyone have tutorials or guides I can look at?

-five


a source to share


2 answers


I think it's about simple $ _GET> requests. <

<?php

$file = $_GET['file'];

if (file_exists($file)) {
   header('Content-Type: application/octet-stream');
   echo file_get_contents($file);
}

?>

      



Of course this is a very simple example without security. It is not recommended for use in manufacturing without safety enhancements.

+2


a source


I'm going to bite ...

The PHP script ensures that the file is not accessible from the outside and only for every request with possible authentication. When you see:

download.php?file=sdjasdk.exe

      



The loading script looks something like this:

<?php
    if( $_SESSION['auth'] == TRUE){
        $file = fileopen($whatever);
        echo "mimetype crap"
        //spit out file
    }else{
        echo "not authorized bozo"
    }
?>

      

Done.

+3


a source







All Articles