MarkGreen
MarkGreen

Reputation: 41

ftp_put in php works only to the root not to sub fulders

I am trying to move images from one server to the other, using ftp_put like this

$des = "example.com/images/";
if (ftp_put($new_ftp, $des, $src, FTP_BINARY))

But I am getting this error.. Warning: ftp_put() [function.ftp-put]: Can't open that file: : No such file or directory!

However when setting the destination on the root it does works.

$des = "example.com"; //works
$des = "example.com/images"; //Does NOT work

Any Idea why?

Upvotes: 1

Views: 293

Answers (2)

MarkGreen
MarkGreen

Reputation: 41

Got it!

it should be

   $des = "/images/"; 

since the root is specified at the connection.

Upvotes: 1

Axel Amthor
Axel Amthor

Reputation: 11106

if it is a directory, check whether it exists and put a / after the name:

$des = "example.com/images/"; 

if the dir wouldn't exist, the sent file would have been named "images"

if it has a slash at the end, it tries to open it as a directory.

The message "No such file or directory!" is the hint: images/ doesn't exist and ftp will not create that for you automatically:

ftp_mkdir ( $new_ftp, $des ); // ignore errors?

Upvotes: 2

Related Questions