Can't find file using php ftp

See attached. Trying to use this to ftp a file from the host the file resides on to another place.

I get this error message:

Warning: ftp_put(): Can't open that file: No such file or directory in /var/www/vhosts/fwsprinkler.com/fwsprinklercdb.info/php_ftp_test.php on line 17 There was a problem while uploading /var/www/vhosts/fwsprinkler.com/fwsprinklercdb.info/pdfwo/wo212397.pdf , error =

The path specified is the absolute path. I had previously used the relative path from where the php file sits. Same error.

The referenced file is in the folder pdfwo.

What's wrong?

Thanks

<<Added by Mr Wolfe>>
php-ftp-test.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ftp_server="00.00.0.000";
$ftp_user_name="my_username";
$ftp_user_pass="xxxxxxxx";
$file = "/var/www/vhosts/_path_to_/pdfwo/wo212397.pdf";//tobe uploaded
$remote_file = "http://www.rkassoc.org/FWLSCO/pdfwo/wo212397.pdf";

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// upload a file
$jj = ftp_put($conn_id, $remote_file, $file, FTP_ASCII);
if ($jj) {
    echo "successfully uploaded $file\n";
    exit;
} else {
    echo "There was a problem while uploading $file , error = " . $jj;
    exit;
    }
// close the connection
ftp_close($conn_id);
?>

Open in new window

Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
FTP does not work with absolute paths.  In FTP, you must change to the target directory and 'put' the file by filename.  "http://www.rkassoc.org/" is not an FTP host either.  And you should edit that file because it has your credentials in it.
0
Richard KortsAuthor Commented:
Dave,

Thanks, I didn't think about what was encoded in that file.

Can you delete the attachment (or can I) off of ee?

Thanks
0
Dave BaldwinFixer of ProblemsCommented:
I can't but one of the moderators can.  You may have to change your password which wouldn't be a bad idea right now anyway.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Richard KortsAuthor Commented:
Dave,

I'm doing that.

Then I'll get back to the question.

Thanks
0
Richard KortsAuthor Commented:
Dave,

OK, I changed the password & made the file path relative.

See attached (password changed).

Same result:

Warning: ftp_put(): Can't open that file: No such file or directory in /var/www/vhosts/fwsprinkler.com/fwsprinklercdb.info/php_ftp_test.php on line 17 There was a problem while uploading pdfwo/wo212397.pdf , error =
php-ftp-test.php
0
Dave BaldwinFixer of ProblemsCommented:
As I said above, FTP will NOT use absolute paths.  You must change to the directory that you want to use for upload or download and then put or get the file (without any path).  You can see that in FTP programs like Filezilla or CoreFTP.
0
hieloCommented:
Try:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ftp_server="00.00.0.000";
$ftp_user_name="my_username";
$ftp_user_pass="abcxyz";
$file = "pdfwo/wo212397.pdf";//tobe uploaded
$remote_file = "FWLSCO/pdfwo/wo212397.pdf";

// Extract the directory and the filename from $remote_file
$remote_dir = substr($remote_file,0,strrpos($remote_file,"/"));
$remote_filename = basename($remote_file);



// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

ftp_chdir($conn_id, $remote_dir);

// upload a file
$jj = ftp_put($conn_id, $remote_filename, $file, FTP_ASCII);
if ($jj) {
    echo "successfully uploaded $file\n";
    exit;
} else {
    echo "There was a problem while uploading $file , error = " . $jj;
    exit;
    }
// close the connection
ftp_close($conn_id);
?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard KortsAuthor Commented:
Excellent, works perfect.

Thanks Dave.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.