Scope of ftp_put function in PHP cant it make transfers between two different location on the same server

There was populist belief spread across the Internet on many forums that a destination can only contain a file name, but I find that to be untrue through experimentation.

I changed the destination carrying just file name, to the path + filename combination, and I find that it works.

Without Path = $destination = $rand.$filename;

​With Path = $destination = “2/”.$rand.$filename;

Similarly, the source may contain a path depending upon the location of the script file; If the script file and “the file to be uploaded” are not in the same location then the path may involve.

Live GIF

Yes, that is correct. The initial problem you had initially was that the path was wrong, so the file you were trying to upload couldn’t be found.

1 Like

True, but I have one more confusion →
ftp_fput( *ftp_conn, remote_file, open_file, mode, startpos* );

startpos → It is to give the path within the FTP folder?

No, I think it’s something to do with partial uploads but I have never used ftp_fput and only ever use ftp_put.

1 Like

By mistake, I posted that but the same logic goes for ftp_put:

Well the answer’s the same. I don’t really know what startpos is for but it’s nothing to do with the path. My guess is it’s to do with uploading a file in chunks but I can’t find much documentation on it.

Note that the spec in the PHP manual shows that startpos should be an integer, which gives you a clue as to what it’s for:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.