• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

rename file (and file extension) on windows

using windows 7
wamp

filename is
1
want to rename to
logo.gif


is there a way to do this with a php script
0
rgb192
Asked:
rgb192
1 Solution
 
Giovanni HewardCommented:
Bear in mind you must release any handles to the file before you can rename it.

<?php
    $fileHand = fopen('1', 'r');
    fclose($fileHand);
    rename( '1', 'logo.gif' );
?>

Open in new window


Also, PHP will be running as whatever user your web server runs as, so you may need to grant proper permissions on the relevant file/folder to the web server user.
0
 
rgb192Author Commented:
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now