0
votes

As the first step FTP connection and login both work. Then I tried

$file_list = ftp_nlist($ftpcon, ".");
var_dump($file_list);

and able to see test folder in the results.

in addition, I checked for directory existence using ftp_chdir and it seems okay,

ftp_chdir($ftpcon, "test")

finally I am trying to upload an image (png) using,

$remote_dir = 'test/';
$src_file = $_FILES['srcfile']['name'];
$remote_file_path = $remote_dir . $src_file;

if (ftp_put($ftpcon, $remote_file_path, $src_file, FTP_BINARY))
    echo 'File uploaded successfully';
else
    echo 'Error uploading file!';

but getting a warning and Error uploading file! message,

ftp_put(image.png): Failed to open stream: No such file or directory

Can anyone point out what I am missing