Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   A simple PHP download script (https://www.warriorforum.com/programming/160317-simple-php-download-script.html)

HomeBizNizz 29th December 2009 12:03 AM

A simple PHP download script
 
In this PHP script you have to write in a 3 letter code (can easily be changed).
And click the submit button.
The PHP script will send the requst to the right file by a PHP redirection to download the right file.

To use it have a subfolder names "files".
Plase your files there.
And edit the filepaths in the PHP script.

You can also place a htaccess file to deny all acess to the file from outside.
And you can also place the filefolder (I think) outside the www-root.

PHP Code:

<?php 

$code 
= $_POST['code'];

if ( 
$code == "rtf" ) {
    
header( 'Location: files/code.rtf' ) ;
}

if ( 
$code == "odt" ) {
    
header( 'Location: files/code.odt' ) ;
}

if ( 
$code == "pdf" ) {
    
header( 'Location: files/code.pdf' ) ;
}

?>

<p>You can choose to download a file.<br />
Choose between 3 file extentions.<br />
Type in the following 3 letter word in <strong>bold</strong> that is either <strong>rtf</strong>, <strong>odt</strong> or <strong>pdf<br />
</strong>This will send a request to the right filetype . </p>
<form name="dl-form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="code">
<input type="submit" name="Submit" value="Submit">
</form>



All times are GMT -6. The time now is 07:22 PM.