Download

Creating a form which selects a downloadable file

I’m wanting to create a form which has a one drop down — these dropdowns reference a file which the customer can then download upon selecting. I’m unsure of the best way to go about this to do it and haven’t found anything to help after a few hours of searching for something Here’s what I have so far:

 

4 Answers 4

You can use code like this:

 

Thank you every one for your responses — I’m sure they’d all work but I went for this answer as it required me to do the least to the code I already had in place — thanks again

You need to put a name on your select in order to hook into it with JavaScript easily.

Then you need an event on your button to call a function:

With jQuery:

           

Or, just pure JavaScript:

         

if I understood correctly, this should do what you’re asking for:

First update your HTML to this:

 

Then create a new file in the same directory that the HTML file is in and call it dl-file.php and put this inside it:

Third, edit the $download_directory to contain where exactly on your hard drive the /downloads/ folder is. Optionally you can add files to the $exclude_files array.

Источник

HTML

The defines a file-select field and a «Browse» button for file uploads.

Читайте также:  Smtp python отправка файлов

To define a file-select field that allows multiple files to be selected, add the multiple attribute.

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attribute
type=»file» 1.0 Yes 1.0 1.0 1.0

Syntax

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

Оцените статью