Let’s say I have following code:
$file="http://example.com/path/to/file.zip";
$in = fopen($file, "r");
var_dump($in); // result - resource(8) of type (stream)
$put = ftp_fput($ftp->getConnectionId(), $file, $in, FTP_BINARY);
var_dump($put); // result - bool(false)
And I am getting following error:
Warning: ftp_fput(): http://example.com/path/to/file.zip: No such file or directory in /var/www/inc/application.php
Connection is established correctly, because I can change directory and read files, but problem appears when I want to upload file as above. What am I doing wrong? Thanks in advance for any help.
The second parameter of
ftp_fputallows you to define the remote file path & name.You are attempting to use a URL instead of a path for your second parameter.
It should be like so:
Source: http://au.php.net/ftp_fput