Welcome Guest, Not a member yet? Register   Sign In
FTP Download: File permissions Question
#1

[eluser]vc27[/eluser]
I've been working to get a simple download to run from one server to another using the ftp class. I think I have my file permissions a little off somewhere, but I'm not sure.

I'll try to explain the scenario, it's pretty simple actually.

Both servers have the file "test-file.txt". The local server needs to download an updated version of the file from the remote server.

I've confirmed that my ftp connection is solid and have used the "list_files" method to confirm the file exists. After confirmation of file existence I run the "download" method.

The servers are virtually identical:
$this->ftp->download( '/home/username/public_html/test/test.txt', '/home/username/public_html/test/test.txt', 'auto' );

The result is that the existing file on the local server is deleted, and the process ends there with an error. "Unable to download the specified file. Please check your path."

After seeing that error I check my path and since I've confirmed the path with list_files I feel like it may be a permissions issue.

I'm fairly new to the concepts of transferring files with php so any suggestion or links would be great.
#2

[eluser]Aken[/eluser]
Maybe this note on the PHP.net ftp_get() page (which the download() method utilizes) may help:

Quote:Please note that the "The remote file path." does not necessarily mean the full server path. If you have created normal user accounts that has been locked into the website folder, you need to enter the remainder of the path.

Example:
If you are getting an image that is located in:
/home/website/public_html/images/image.jpg

And you have locked the user into: /home/website/

Then the path you should pass along when fetching the file is:
public_html/images/image.jpg
#3

[eluser]vc27[/eluser]
Thank you so much, that was it.

I'm constantly amazed how close I am to the solution and yet so blind to it :p
#4

[eluser]Aken[/eluser]
Take a look at the source code next time if you experience a similar problem. You might find a native PHP function in it whose corresponding page has something helpful on it, like this. Smile Viewing the source code answers a lot of questions sometimes, but a lot of people don't take the time.
#5

[eluser]vc27[/eluser]
Totally agree, and after I read the answer I was thinking the same thing, "i could have just looked at the source". Follow back the functions that make things happen and you find all the goodies!




Theme © iAndrew 2016 - Forum software by © MyBB