Jump to content

[SOLVED] Passing chosen filename to my download.php


gbuck

Recommended Posts

I have a form with a <select> box that I populate with filenames from a folder on the server using PHP. I want to go to the Force Download dialog box when the submit button is clicked for the file the user has chosen in the drop-down box.

 

My PHP skills (apart from the most basic uses) at this point involve a lot of hunting in books and online for code samples I can tweak. My problem is that every example I've seen of a force-download script requires the typed filename.

 

It seems really simple but but I'm having trouble. Is the filename already passed as variable in the _POST array? I currently using a GET method for the form.

 

Is the filename already passed as variable in the _POST array? I currently using a GET method for the form.

 

Yes if you did used something like:

<select name="filename">
    <option value="a-filename.ext">Filename</option>
</select>

 

You can access it using:

$_POST['filename'] /*or*/ $_GET['filename']

 

Depending on the request method you used.

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.