Jump to content

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.

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.