• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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