Re: FTP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gustav Wiberg wrote:
Hi all!

I took this code directly from PHP.net but I don't get it to work correctly...I've never worked with ftp-connections with PHP before...


<?php

$ftp_server = "ftp.example.com";
$ftp_user = "foo";
$ftp_pass = "bar";

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
  echo "Connected as $ftp_user@$ftp_server\n";
} else {
  echo "Couldn't connect as $ftp_user\n";
}

// close the connection
ftp_close($conn_id);
?>

It seems to work fine when I'm trying on my testmachiner (WIndows XP + Apache) , but when I put the file on the webserver at my webhost (b-one), then I just get a blank page and showing source-code like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

What could be the problem?

Is your web host running something other than Windows? Does it have the ftp functions enabled? Make a phpinfo page, and access that in your browser to see if the ftp functions are enabled. You are more than likely not seeing the error on your host because they have error reporting turned off. You can use ini_set to switch this if you want.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux