-
March 14th, 2011, 04:57 PM
#1
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
-
March 14th, 2011, 06:16 PM
#2
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?
-
March 14th, 2011, 06:31 PM
#3
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.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 15th, 2011, 04:40 AM
#4
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 "/").
-
March 15th, 2011, 10:55 AM
#5
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
Last edited by Andrzej; March 15th, 2011 at 11:16 AM.
-
March 15th, 2011, 11:45 AM
#6
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' ( / )
-
March 15th, 2011, 11:59 AM
#7
Re: ftp_put(), problem with relative path
Originally Posted by PeejAvery
... and the root directory you're starting from is correct.
That's what this meant.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 15th, 2011, 12:21 PM
#8
Re: ftp_put(), problem with relative path
Originally Posted by PeejAvery
That's what this meant.
thanks PeejAvery, know I've understood your unswer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|