FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2002, 01:52 PM
s_schimmel s_schimmel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: The Netherlands
Posts: 19 s_schimmel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 43 sec
Reputation Power: 0
Send a message via ICQ to s_schimmel
download files using ftp and php

Hi,

I want to download files from a ftp server using a php script with ftp_get(). Is it possible to download files from a server using a script with ftp_get. I mean are the files saved on the users computer or on the webserver? I want to use this script on computers that are behind a firewall that only alows access to the internet on port 80 and the http protocol.

I've got this:
PHP Code:
<?php
// set up basic connection
$conn_id ftp_connect($server);

// login with username and password
$login_result ftp_login($conn_id$naam$w8);

// check connection
if ((!$conn_id) || (!$login_result)) {
       echo 
"Ftp connection has failed!";
       echo 
"Attempted to connect to $ftp_server for user $ftp_user_name";
       die;
   } else {
       echo 
"Connected to $ftp_server, for user $ftp_user_name";
   }

// upload the file
$upload ftp_get($conn_id$naar$bestandFTP_BINARY);

// check upload status
if (!$upload) {
       echo 
"Ftp download has failed!";
   } else {
       echo 
"Download $bestand from $server as $naar";
   }

// close the FTP stream
ftp_close($conn_id);

?>


Thanks,

Sebastiaan

Reply With Quote
  #2  
Old May 29th, 2002, 03:50 PM
Schnotz Schnotz is offline
hmm...
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Nashville
Posts: 50 Schnotz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 18 sec
Reputation Power: 8
Since PHP is a server side langauage, the files you fetch will end up on the web server.
You can however force a download box to appear on the users machine by passing the downloaded file forward to the browser after it has finished downloading. (Everything takes place behind the scenes from the clients point of view)

There are threads here in the forum on how to do this. I don't know the exact syntax without some research, but as I mentioned. It has been discussed before about how to make the download box appear on the clients box.

1. Make the ftp connection and retrieve the files into a location on the server.
2. Find the threads that talk about making the download box appear and pass through the files to that, so the user will have the option of saving the files.
(if there are multiple files, you might want to zip them together before you pass them through).
3. Done.

Hope this will get you started

About the firewall.
They better have a very good reason for not letting the users make outside ftp connections. It is one thing, not letting users from the outside make ftp connections to the private network, but the other way around? I don't know. I assume you do.

Reply With Quote
  #3  
Old June 1st, 2002, 11:08 AM
s_schimmel s_schimmel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: The Netherlands
Posts: 19 s_schimmel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 43 sec
Reputation Power: 0
Send a message via ICQ to s_schimmel
Thanks.

Preventing acces to ftp servers is to prevent students to download the newest movies and games. Our school doesn't like that

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > download files using ftp and php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT