Solved

rename file (and file extension) on windows

Posted on 2013-02-06
2
269 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
2 Comments
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my wamp get_include_path() wrong? 2 21
Custom Wordpress Loop 22 39
PHP Curl to output a url 7 53
Returning errors to display in a dialog box - Ajax, Json, Php 16 34
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

820 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