Click to See Complete Forum and Search --> : PHP ftp_put(), problem with relative path
Andrzej
March 14th, 2011, 04:57 PM
Hello
I would like to upload a file:
script php with ftp_put() is on the: /public_html/mleko/ftp.php
source file is on the /public_html/mleko/temp.txt
remote file should be uploaded to /public_ftp/mleko/uploadedfile.txt
could you please tell me what is wrong with code as below:
$result = ftp_put( '/public_ftp/mleko/uploadedfile.txt', 'temp.txt', FTP_ASCII );
I receive an error:
"... no such file or directory ... "
thanks in advance
andrzej
S_M_A
March 14th, 2011, 06:16 PM
Have no experience in this field but my guess is that the default directory is not where temp.txt is located. Are you calling/running ftp.php from another dir?
PeejAvery
March 14th, 2011, 06:31 PM
Very simple, you're accessing a directory that isn't there...exactly what the message says. Make sure the path you're writing to already exists and the root directory you're starting from is correct.
olivthill2
March 15th, 2011, 04:40 AM
The root directory is the one defined in a configuration file of Apache (if that's your server), and it is likely it is different from the root directory of the hard drive.
Personnally, I avoid troubles by using relative paths (a relative path is a path that does not start with "/").
Andrzej
March 15th, 2011, 10:55 AM
thanks for the reply,
could you please give me the example, what my ftp_put() function parameter should be
to clarify:
my ftp.php script ( which includes ftp_put() ) is located on the:
/public_html/mleko/ftp.php
my file which need to be uploaded is located on the:
/public_html/mleko/tmp.txt
I need to upload the tmp.file to:
/public_ftp/data/ftp.php
I did it as follows ( but the error '..no such file or directory ..' is generated
$remote_path='/public_ftp/data/mleko/';
//$remote_path='../../public_ftp/data/mleko/'; // also doesn't work
$local_file_name='tmp.txt';
$new_file_name='uploaded.txt';
$result = ftp_put($remote_path . $new_file_name, $local_file_name, FTP_ASCII );
thank you in advance
Andrzej
Andrzej
March 15th, 2011, 11:45 AM
I solved ...
$remote_path must be RELAVIVE PATH TO YOUR LOGIN DIRECTORY
I have change my login directory and now it works OK !
this is OK
$remote_path='../../public_ftp/data/mleko/';
but the ftp login directory must be to the 'root' ( / )
PeejAvery
March 15th, 2011, 11:59 AM
... and the root directory you're starting from is correct.
That's what this meant.
Andrzej
March 15th, 2011, 12:21 PM
That's what this meant.
thanks PeejAvery, know I've understood your unswer.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.