Hi Edward
Look at ftp_set_option in the manual, you can access it online at
http://www.php.net/manual/en/function.ftp-set-option.php.
FTP_TIMEOUT_SEC sounds like it might do what you are looking for.
Jason
----- Original Message -----
From: "Edward van Bilderbeek - Bean IT" <[EMAIL PROTECTED]>
To: "PHP-General" <[EMAIL PROTECTED]>
Sent: Thursday, April 04, 2002 6:16 AM
Subject: [PHP] FTP
> Hi,
>
> I'm creating an FTP script for uploading files... but now, when I pull out
> the network plug of the server (so the connection is lost), my program
> doesn't stop running... any ideas of how to check if a connection is still
> alive?
>
> Edward
>
>
> // partial code:
>
> for ($i=0; $i<mysql_numrows($query); $i++) {
> $ip = mysql_result($query, 0, 'locatie.ip');
> $titel = mysql_result($query, 0, 'locatie.titel');
> $gebruiker = mysql_result($query, 0, 'locatie.gebruiker');
> $wachtwoord = mysql_result($query, 0, 'locatie.wachtwoord');
>
> $connid = ftp_connect($ip);
> $login_result = ftp_login($connid, $gebruiker, $wachtwoord);
>
> if (!$connid || ! $login_result) {
> $error[] = array("con", "FTP connection failed at $titel ($ip) for
> $gebruiker");
> } else {
> $query_ftp = mysql_query("SELECT * FROM bestanden WHERE
> locatienummer='$locatienummer' && code != 'N'");
> for ($j=0; $j<mysql_numrows($query_ftp); $j++) {
> $id = mysql_result($query_ftp, $j, 'id');
> $bestand = mysql_result($query_ftp, $j, 'path');
> $code = mysql_result($query_ftp, $j, 'code');
> $doel = eregi_replace("^$path/", "", $bestand);
>
> ftp_chdir($connid, "~");
> if (strtolower(substr($bestand, -3))=='txt' ||
> strtolower(substr($bestand, -3))=='sca') {
> $upload = @ftp_put($connid, $doel, $bestand,
> FTP_ASCII);
> } else {
> $upload = @ftp_put($connid, $doel, $bestand,
> FTP_BINARY);
> }
> if (!$upload) {
> $error[] = array("upl", "Upload failed: $bestand, at:
> $titel ($ip) for $gebruiker");
> } else {
> mysql_query("UPDATE bestanden SET code='N' WHERE
> id='$id'");
> }
> }
> if (!ftp_exec($connid, "NOOP")) {
> /// ********* HERE I WANNA CHECK OF THERE IS A CONNECTION
> /// ********* BUT IT LOOKS LIKE IT KEEPS TRYING TO SEND
THE
> FILES
> /// ********* AND GETS STUCK IN THE ftp_put()'s ABOVE...
>
> $error[] = array("lost", "Connection lost to $titel ($ip)
for
> $gebruiker");
> break;
> }
> }
> }
> ftp_quit($connid);
> }
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php