ftp_put(), problem with relative path
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:
PHP Code:
$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
Re: ftp_put(), problem with relative path
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?
Re: ftp_put(), problem with relative path
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.
Re: ftp_put(), problem with relative path
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 "/").
Re: ftp_put(), problem with relative path
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
PHP Code:
$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
Re: ftp_put(), problem with relative path (solved)
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' ( / )
Re: ftp_put(), problem with relative path
Quote:
Originally Posted by
PeejAvery
... and the root directory you're starting from is correct.
That's what this meant.
Re: ftp_put(), problem with relative path
Quote:
Originally Posted by
PeejAvery
That's what this meant.
thanks PeejAvery, know I've understood your unswer.