James
James

Reputation: 43617

PHP rename file on same host

$url = 'http://site.com/images/name.jpg';

Its a full path for the file, which is already exists on ftp.

How can I change file's name?

Upvotes: 0

Views: 2771

Answers (3)

Pekka
Pekka

Reputation: 449385

As others already point out, the PHP function you're looking for is rename, but you can't rename a file through a http:// URL (At least not in PHP - As @Artefacto says, WebDAV can do this.).

You will need to specify a proper filesystem path.

Upvotes: 5

aularon
aularon

Reputation: 11110

if your script on the server root (http://site.com/script.php) that script will do:

rename('images/oldname.jpg', 'images/newname.jpg');

since that's the relative path of the image from the script point of view.

Upvotes: 5

GoalieGuy6
GoalieGuy6

Reputation: 522

Check out the rename() function. Seems to be what you're looking for here.

http://php.net/manual/en/function.rename.php

Upvotes: 0

Related Questions