Problem - ftp_put() returns FALSE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jayesch
Forum Newbie
Posts: 1
Joined: Mon Sep 22, 2008 2:16 am

Problem - ftp_put() returns FALSE

Post by jayesch »

Hello,

I see this weird problem with ftp_put. I have checked for all common sources of errors and find that none of them apply for my case.

1) I can do ftp_chdir() to destination directory with success
2) I have write access the the destination directory.
3) I can upload files to FTP server from windows command prompt or other FTP clients.
4) File source path has no spaces in it(C:\test.txt)


Unfortunately I do not have access to FTP server logs. FTP server is hosted on a MAC machine with OS-X 10.0

Here is the code snippet =

Code: Select all

 
$ftp_user_name='user';
$ftp_user_pass='password';
$ftp_server='somehost';
$destination_file='test.txt';
$src_file='c:\test.txt';
 
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if(!ftp_chdir($conn_id,'/Documents/MobileMedia/site/uploads/video/mpeg'))
{         
  echo "No read permission in the destination directory </br>";
}       
if(!ftp_put($conn_id, $destination_file, $src_file, FTP_BINARY))
{
  echo "Upload operation to FTP server failed </br>";
}   
ftp_close($conn_id);
 
Let me know if there is anything wrong or there exists any other source of error.
jahwobbler
Forum Newbie
Posts: 2
Joined: Tue Dec 09, 2008 5:26 pm

Re: Problem - ftp_put() returns FALSE

Post by jahwobbler »

jayesch wrote:Hello,

I see this weird problem with ftp_put. I have checked for all common sources of errors and find that none of them apply for my case.

1) I can do ftp_chdir() to destination directory with success
2) I have write access the the destination directory.
3) I can upload files to FTP server from windows command prompt or other FTP clients.
4) File source path has no spaces in it(C:\test.txt)


Unfortunately I do not have access to FTP server logs. FTP server is hosted on a MAC machine with OS-X 10.0

Here is the code snippet =

Code: Select all

 
$ftp_user_name='user';
$ftp_user_pass='password';
$ftp_server='somehost';
$destination_file='test.txt';
$src_file='c:\test.txt';
 
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if(!ftp_chdir($conn_id,'/Documents/MobileMedia/site/uploads/video/mpeg'))
{         
  echo "No read permission in the destination directory </br>";
}       
if(!ftp_put($conn_id, $destination_file, $src_file, FTP_BINARY))
{
  echo "Upload operation to FTP server failed </br>";
}   
ftp_close($conn_id);
 
Let me know if there is anything wrong or there exists any other source of error.
Post Reply