Hello, I am having problems with the ftp_put() function. I can login
via shell prompt.
Does anyone know why the ftp_put() function may not work? I went to the
php site and followed the directions. I am connecting because I am not
getting an error. I am also logging in with the username and password
because I am not getting an error here as well. But so far no matter
what I do, the file will not upload.
Any help with this would be great.
code:
$query = "select Server, UserName, Password, Destination_Pat h,
ServerType from company";
$result = @mysql_query($q uery);
$row = @mysql_fetch_ar ray($result);
if (!empty($row["Server"]))
{
$hostip = gethostbyname($ row["Server"]);
$conn_id = ftp_connect($ho stip);
// set up basic connection
//$conn_id = ftp_connect($ro w["Server"]);
// login with username and password
$login_result = ftp_login($conn _id, $row["UserName"],
$row["Password"]);
// check connection
if ((!$conn_id) || (!$login_result ))
{
$value = "FTP connection has failed!<br>
Attempted to connect to ".$row["Server"]." for user ".$row["UserName"];
exit;
}
// IMPORTANT!!! turn passive mode on
//tried this and it did not help
//ftp_pasv ( $conn_id, true );
//parameters are ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_BINARY)
$upload = ftp_put($conn_i d, $row["Destination_Pa th"]."/".
strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), FTP_BINARY);
if (!$upload)
echo $upload."<br><b r>Did not upload to ftp server.";
// close the FTP stream
ftp_close($conn _id);
}
I am not getting any errors and the file is not getting uploaded.
-my server var holds the URl of the server ex. 'test.com'
- my destination file var holds the path temp
so the destination path when I echo it is temp/my file
so the ftp_put() is getting passed
ftp_put($conn_i d, 'temp/myfile', 'myfile', ftp_binary);
This is the first time I have ever used this function so please bear
with me. I have researched it and no one seems to have this problem.
Most people complain that the file seems to get uploaded but its file
size is 0. Right now, my page runs and nothing happens. My permissions
on the server are correct, the folder I am trying to upload to exists,
the username and pass are correct and I can login via shell prompt as
well.
Any ideas?
Thanks
via shell prompt.
Does anyone know why the ftp_put() function may not work? I went to the
php site and followed the directions. I am connecting because I am not
getting an error. I am also logging in with the username and password
because I am not getting an error here as well. But so far no matter
what I do, the file will not upload.
Any help with this would be great.
code:
$query = "select Server, UserName, Password, Destination_Pat h,
ServerType from company";
$result = @mysql_query($q uery);
$row = @mysql_fetch_ar ray($result);
if (!empty($row["Server"]))
{
$hostip = gethostbyname($ row["Server"]);
$conn_id = ftp_connect($ho stip);
// set up basic connection
//$conn_id = ftp_connect($ro w["Server"]);
// login with username and password
$login_result = ftp_login($conn _id, $row["UserName"],
$row["Password"]);
// check connection
if ((!$conn_id) || (!$login_result ))
{
$value = "FTP connection has failed!<br>
Attempted to connect to ".$row["Server"]." for user ".$row["UserName"];
exit;
}
// IMPORTANT!!! turn passive mode on
//tried this and it did not help
//ftp_pasv ( $conn_id, true );
//parameters are ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_BINARY)
$upload = ftp_put($conn_i d, $row["Destination_Pa th"]."/".
strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), FTP_BINARY);
if (!$upload)
echo $upload."<br><b r>Did not upload to ftp server.";
// close the FTP stream
ftp_close($conn _id);
}
I am not getting any errors and the file is not getting uploaded.
-my server var holds the URl of the server ex. 'test.com'
- my destination file var holds the path temp
so the destination path when I echo it is temp/my file
so the ftp_put() is getting passed
ftp_put($conn_i d, 'temp/myfile', 'myfile', ftp_binary);
This is the first time I have ever used this function so please bear
with me. I have researched it and no one seems to have this problem.
Most people complain that the file seems to get uploaded but its file
size is 0. Right now, my page runs and nothing happens. My permissions
on the server are correct, the folder I am trying to upload to exists,
the username and pass are correct and I can login via shell prompt as
well.
Any ideas?
Thanks
Comment