?
Solved

rename file (and file extension) on windows

Posted on 2013-02-06
2
Medium Priority
?
286 Views
Last Modified: 2013-02-06
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
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 2000 total points
ID: 38860381
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
 

Author Closing Comment

by:rgb192
ID: 38860803
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question