DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

ftp script

By: | 18 Feb 2009 4:25 pm

Hi,

Im working on a ftp script and right now Im just learning from the script on the php site.

This line:

$upload = ftp_put($connection_id, $destination_file, $source, FTP_BINARY);

Im having trouble with: $destination_file

destination file is the remote file path.
So I assume that to be
ftp.servername.com
/ root
/images images directory

so I put $destination_file = "/images";
Warning: ftp_put() [function.ftp-put]: Can`t open that file: Is a directory in ftp_upload_script.php on line 23
FTP upload has failed!

I did try images/ for the destination but that was a invalid path it
said. So I tried /images/ and the same for that.

I just dont understand what its asking for.

Comments

Hello,

The server name or IP address should be used when you open the port connection along with the username and password. The remote file path is not needed or accepted when you are opening the connection.

A relative path may work depending on the FTP config ie `images/` or `public_html/images/` or you may need to find the full path ie `/usr/www/useres/servername/account/home/public_html/images/`. A relative path cannot start with a (back)slash.

The destination must also have the file name ie /www/home/public_html/mypic.jpg as this can be different to the source file name.

Another problem you will see at times is sym links. The public_html may not actually be a folder but just a sym link to another folder like a shortcut in Windows. It is best to use the real file past. Although Apache may follow sym links for http, it may not follow them for ftp depending on the local config. This is especially true for shared servers.

Apache treats folders and files in a similar way. Opening a read stream to a folder returns a directory listing and opening a read stream to file returns the data in the file.

Hope tis helps.

By: | 18 Feb 2009

$upload = ftp_put($connection_id, $destination_file, $source, FTP_BINARY);

Im having trouble with: $destination_file

destination file is the remote file path.
So I assume that to be
ftp.servername.com
/ root
/images images directory

so I put $destination_file = "/images";
Warning: ftp_put() [function.ftp-put]: Can`t open that file: Is a
directory in ftp_upload_script.php on line 23
FTP upload has failed!
Hey Wade, I think that the $destination_file needs to be the actual
filename.

$destination_file = `MY_FILE.txt`;
It`s the remote FILE not the remote directory:

bool ftp_put ( resource $ftp_stream , string $remote_file , string
$local_file , int $mode [, int $startpos ] )

By: | 18 Feb 2009

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move