Jassi
Jassi

Reputation: 31

Moving file on remote server using PHP and FTP

I want to move the file from folder to another folder in the remote server using FTP on PHP, but I did not found any function to do this.

Can anyone help me in this case?

Upvotes: 2

Views: 7549

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202168

Use ftp_rename function.

Rename and move are the same file system operations. It does not matter, if you move/rename a file from one name to another within the same folder. Or if you move a file from one folder to another.

Upvotes: 4

Marina
Marina

Reputation: 1

Are you using any specific framework? If not, PHP has built in functions that deal with ftp files. You can view those in the documentation: http://php.net/manual/en/ref.ftp.php

If you're just moving the file, you can probably use a combination of ftp_fget ("Downloads a file from the FTP server and saves to an open file"), ftp_delete ("Deletes a file on the FTP server"), and ftp_fput ("Uploads from an open file to the FTP server") after establishing a connection with ftp_connect.

Upvotes: -1

Related Questions