Jump to content

How to use PHP to start a DOWNLOAD (like you do in the PHP Freaks Code Library)


andrechance

Recommended Posts

I would like to use a PHP script to initiate a file DOWNLOAD (download, not upload.)

 

My motivation is to hide the full path names from the users -- who might be tempted to figure out the file naming convention and type those names directly in their browsers, instead of going through the regular website pages (which check for authentication.)

 

Anyway, I noticed that the PHP Freaks Code Library pages have exactly such a thing: a Download button.

 

For example, http://www.phpfreaks.com/quickcode/Page-Counter/73.php offers a Download button.  I looked at the source file, and saw that it contains:

 

<form method="post" action="/quickcode.php">

<input type="hidden" name="cmd" value="doDownload" />

<input type="hidden" name="quickcode_id" value="73" />

Choose Type:

<select name="type"><option value="tar">Linux (Tarball)</option><option value="zip">Windows (Zip File)</option>

</select>

<input type="submit" value="Download" onclick="if ( !window.confirm( 'By downloading this file, you accept it at your own risk. PHPFreaks does not guarantee this code or what it will do to your system!' ) ) { return false; };" />

 

</form>

 

 

It looks like the "quickcode.php" script works together with the above form to initiate a file download...

 

What does such a script consist of?  Thanks!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.