Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using PHP to create downloadable links to files in a dir
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Fri Oct 04, 2013 12:01 pm    Post subject: Using PHP to create downloadable links to files in a dir Reply with quote

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
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Fri Oct 04, 2013 9:00 pm    Post subject: Reply with quote

Start Here:
PHP: ScanDir
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Sun Oct 06, 2013 7:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6050
Location: Removed by Neddy

PostPosted: Sun Oct 06, 2013 8:08 pm    Post subject: Reply with quote

^^
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
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sun Oct 06, 2013 9:47 pm    Post subject: Reply with quote

I've used webfs for similar purpose. http://linux.bytesex.org/misc/webfs.html
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Thu Oct 10, 2013 12:35 am    Post subject: Reply with quote

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
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Thu Oct 10, 2013 9:30 pm    Post subject: Reply with quote

Using Apache's headers, footers and a bit of CSS, you may achieve fancy things as well :D
Back to top
View user's profile Send private message
666threesixes666
Veteran
Veteran


Joined: 31 May 2011
Posts: 1248
Location: 42.68n 85.41w

PostPosted: Thu Oct 10, 2013 10:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Sat Oct 12, 2013 9:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum