View previous topic :: View next topic |
Author |
Message |
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Fri Oct 04, 2013 12:01 pm Post subject: Using PHP to create downloadable links to files in a dir |
|
|
I am a systems engineer that is just starting to learn and use (and love) php, but I have some time constraints. Currently I have a bunch of files in a directory that our account managers have to scp/sftp to ther PC, and I would like to build a web page that they can hit to download the files, therefore avoiding client software and the need to authenticate. From what I seen of PHP i suspect that this is not going to be very difficult!
As always any help is much appreciated! _________________ Brent Weaver |
|
Back to top |
|
|
eyoung100 Veteran
Joined: 23 Jan 2004 Posts: 1428
|
|
Back to top |
|
|
destroyedlolo l33t
Joined: 17 Jun 2011 Posts: 846 Location: Close to Annecy (France)
|
Posted: Sun Oct 06, 2013 7:34 pm Post subject: |
|
|
Hum, why do you want to use PHP for that ?
You have only to install apache and use mod_autoindex. More, Apache is smart enough to let you play with MIME type based on file extension like
Code: | <FilesMatch "\.(lha|tgz)$">
ForceType application/octet-stream
</FilesMatch>
|
Bye |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Sun Oct 06, 2013 8:08 pm Post subject: |
|
|
^^
exactly, pretty much every httpd comes with a module/option to dirlist. In fact python comes with a httpd that will just serve the files from a directory.
NOW if you want to learn php thats different, its a nice little exercise to break you into it. I personally would do it via py (and kinda do for some of my stuff) _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Thu Oct 10, 2013 12:35 am Post subject: |
|
|
Hey guys. Thank you all for your responses. The reason I am looking at PHP is because I would like it to be a bit fancier than say, webs. Perhaps I am chasing my ego too much but I would love to have this looking professional....
<?php
$dir = '/etc';
$files1 = scandir($dir);
## Now create the loop
foreach($files1 as $xx) {
print "<br>$xx"; }
?> _________________ Brent Weaver |
|
Back to top |
|
|
destroyedlolo l33t
Joined: 17 Jun 2011 Posts: 846 Location: Close to Annecy (France)
|
Posted: Thu Oct 10, 2013 9:30 pm Post subject: |
|
|
Using Apache's headers, footers and a bit of CSS, you may achieve fancy things as well |
|
Back to top |
|
|
666threesixes666 Veteran
Joined: 31 May 2011 Posts: 1248 Location: 42.68n 85.41w
|
Posted: Thu Oct 10, 2013 10:06 pm Post subject: |
|
|
mod_autoindex controls the directory created.
/etc/apache2/modules.d/00_mod_autoindex.conf
needs
Code: |
IndexStyleSheet "/index.css"
|
inserted above </IfModule>
then drop your custom styling into /var/www/localhost/htdocs/index.css
(i put it in a location that will probably collide with your existing css to make the directories behave as the rest of the site does.)
as you can see my apache share directory went from black text on white background, to white text on black background.... http://imageshack.com/a/img600/6729/6apy.jpg
(please, more detail about the headers and footers?) |
|
Back to top |
|
|
destroyedlolo l33t
Joined: 17 Jun 2011 Posts: 846 Location: Close to Annecy (France)
|
Posted: Sat Oct 12, 2013 9:49 pm Post subject: |
|
|
666threesixes666 wrote: | (please, more detail about the headers and footers?) |
Well :
- HeaderName to customize what is above the directory listing
- ReadmeName to customize what is bellow the directory listing
|
|
Back to top |
|
|
|