Hi,
Im rather new to web dev, or returning...
How do I make a HTML web page that lists files that a user can click on and download?
Is it really that complex? ASP.. jsp.. etc etc... NO! its cant be that complex... I just want to list files and give the option to save them back to the local machine...
But its like I have just discovered that 20ys of HTML has evolved to not allowing this ???
Can anyone give some practical strategy?
Page 1 of 1
Save a file ? A basic web page that allows the user to download a file?
#2
Posted 14 January 2012 - 08:27 AM
just give them a folder on your server that they can view? No HTML required.
#3
Posted 14 January 2012 - 09:23 AM
save the file in a .zip and upload the zip? same as it always has been?
#4
Posted 14 January 2012 - 12:24 PM
Generally you would just have to link the file to someone and it will be downloaded automatically. But some browsers act differently with some file extensions.
For example take Google Chrome. If I clicked a link with a .mp3 extension, chrome will play it straight through the browser rather than downloading it. In situations like this, you can choose to just switch to a different browser that doesn't have the inbuilt player. Or you could use php to force a download with a little bit of server headers.
Something like this:
The latter would be my personal option.
For example take Google Chrome. If I clicked a link with a .mp3 extension, chrome will play it straight through the browser rather than downloading it. In situations like this, you can choose to just switch to a different browser that doesn't have the inbuilt player. Or you could use php to force a download with a little bit of server headers.
Something like this:
<?php
header('Content-type: audio/mpeg');
header('Content-disposition: attachment; filename=samus.mp3');
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
?>
The latter would be my personal option.
#5
Posted 14 January 2012 - 10:44 PM
Samus, on 14 January 2012 - 12:24 PM, said:
Generally you would just have to link the file to someone and it will be downloaded automatically. But some browsers act differently with some file extensions.
For example take Google Chrome. If I clicked a link with a .mp3 extension, chrome will play it straight through the browser rather than downloading it. In situations like this, you can choose to just switch to a different browser that doesn't have the inbuilt player. Or you could use php to force a download with a little bit of server headers.
Something like this:
The latter would be my personal option.
For example take Google Chrome. If I clicked a link with a .mp3 extension, chrome will play it straight through the browser rather than downloading it. In situations like this, you can choose to just switch to a different browser that doesn't have the inbuilt player. Or you could use php to force a download with a little bit of server headers.
Something like this:
<?php
header('Content-type: audio/mpeg');
header('Content-disposition: attachment; filename=samus.mp3');
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
?>
The latter would be my personal option.
Thanks for the suggestions... Samus esp. I will have to 'try' the above php solution.
Just to be clear... And maybe get a bit more advice...
Its a piece of a web page/application I just want to make my life easier...
I want the user to click a button( i can do that) be shown a fresh list of the files there.. and choose one to 'save as'
The files are just txt. the save as diag comes up and I same my file to my laptop.
I think I can just about handle php and HTML, xml, but the rest sadly is beyond my radar. i.e if you find yourself looking up ASP on wikipedia... its maybe not a good idea to start trying to implement something with it.. hehe.
Even outside of the box ideas are welcome... Am I over complicating this?
#6
Posted 14 January 2012 - 11:43 PM
If you already have PHP experience, i'd suggest you jump straight into a framework, specifically codeigniter. There are several libraries and functions that make tasks like this easier, especially when developing an app.
For example, the download helper
Only pass 2 arguements to the function, the name you want the downloaded files to be called and the file's location. And all the appropriate headers are created for that download.
For example, the download helper
Only pass 2 arguements to the function, the name you want the downloaded files to be called and the file's location. And all the appropriate headers are created for that download.
- ← setTImeout function not working in firefox
- CSS, XHTML/HTML & JavaScript
- Menu fine in FF but not functioning in IE ? →
Share this topic:
Page 1 of 1
Help















