HTML5 download Attribute

 
The download attribute allows you to set a separate file download name than the actual link endpoint itself.
 
 
Place the download attribute on a link in html file.
 
Example
 
<!– will download as "jijokjose.zip" –>
 
<a href="http://www.jijokjose.com/wp-content/uploads/2013/01/ajax_auto_complete.zip" download="jijokjose.zip">Download Sample File</a>
 
Result
 
 
..and when the user clicks the link, the download attribute appears in the save dialog instead of the garbled mess that was there before.
 

In this case, the file will be downloaded as jijokjose.zip. The download attribute also triggers a force download, something that is used to do on the server side with PHP.
 
This attribute is extremely useful in cases where generated files are in use — the file name on the server side needs to be incredibly unique, but the download attribute allows the file name to be meaningful to user.  
 
The download attribute is one of those enhancements that is practical and easy to add.

 
You can leave a response, or trackback from your own site.

Leave a Reply