[thelist] PHP plus FTP (fwd)

Daniel J. Cody djc at members.evolt.org
Fri Aug 3 15:18:24 CDT 2001


FYI folks, the correct address to post to thelist is
thelist at lists.evolt.org :)

---------- Forwarded message ----------
Date: Fri, 3 Aug 2001 11:59:13 -0400
From: Kevin Martin <evolt at brasscannon.com>
To: thelist at evolt.org
Subject: PHP plus FTP

Hey, there!  I have a client who wants a real simple HTML interface to
a ftp site.  (Think Dilbert's pointy-haired boss.)

I got an example app using PHP from Melonfire (www.melonfire.com); it 
claims to do exactly what I need, and for uploads it works great, but
the download part has me buffaloed.  If I fiddle with directory 
permissions in a way that makes me quite nervous, I can get it to
copy a file from one directory to another ON THE SERVER -- but I can't
get it to ftp anything to my PC.  The PHP "Big Manual" at php.net is
somewhat cryptic on the "ftp_get" command.

<!-- code snippet liberally adapted from Melonfire's "Beam Me Up, Scotty" 
example -- they are not responsible for my butchery -->

// download selected files
// IMPORTANT: This fails unless the webserver's userid
// has WRITE privileges --  e.g. chown apache /home/username/http
//
$good_dir="/home/".$username."/http";
for ($x=0; $x<sizeof($dfile); $x++)
{
$tmpfile = $dfile[$x];
ftp_get($result, $good_dir."/".$tmpfile, $dfile[$x], FTP_BINARY);
}
<!-- End --> 

As a workaround, I'm generating an array of filenames and presenting
them as HTTP links, and using the Melonfire code for uploads; but
I have to remind the user to right-click (or whatever the equivalent is 
for various browsers) and do "Save link as" -- and one can't assume that
my users will read those instructions. 

Neither am I looking forward to writing/stealing the code to identify the 
user's browswer and give him/her appropriately customized instructions, 
which my pride would require.

Any help on making this thing do an ftp download to the user's machine
would be most welcome!  Server machine is a Linux box, and I have root.

-- 
Kevin 'digger' Martin <evolt at brasscannon.com>
"Dammit, Jim, I'm an Admin, not a Webmaster!"





More information about the thelist mailing list