Connecting Tech Pros Worldwide Help | Site Map

Move & Rename file to new directory

  #1  
Old June 30th, 2009, 04:10 PM
Newbie
 
Join Date: Jun 2009
Posts: 14
Hi guys.

I'm having a problem with this case.

I want a php script activated by a standard file submit to:
1) upload the file to ../../upload
2) copy the file to a directory further back, for example .././latest/../..
3) rename the file, no matter what name it has - to play.html

So far I got the upload working and the file is uploaded to the folder /upload.
But i dont know how to copy it or rename it at the same time.

I dont want to just move it because I would like to keep the original file in the /upload directory.


How can I do this?
Thanks
  #2  
Old June 30th, 2009, 08:07 PM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,485
Provided Answers: 9

re: Move & Rename file to new directory


copy()

rename()

would be the obvious thing to try first.
  #3  
Old June 30th, 2009, 08:11 PM
Newbie
 
Join Date: Jun 2009
Posts: 14

re: Move & Rename file to new directory


Yeah thanks
I did look at it, but Im brand new to PHP so I dont know how to incorporate my own paths to these.

If anyone could show me how it would look that would be great.
  #4  
Old June 30th, 2009, 08:17 PM
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,075

re: Move & Rename file to new directory


This is how it looks.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. copy($uploadedFileName, "/var/www/latest/play.html");
  3. ?>
  4.  
Where $uploadedFileName contains the name of the file that was upload. You should already have this if you successfully uploaded the file.



Dan
  #5  
Old June 30th, 2009, 08:28 PM
Newbie
 
Join Date: Jun 2009
Posts: 14

re: Move & Rename file to new directory


Would this work to define the uploaded files' name

$uploadedFileName = $HTTP_POST_FILES['ufile']['name']

?
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
[perl-python] find & replace strings for all files in a dir Xah Lee answers 1 July 18th, 2005 09:55 PM
php-4.3.4-Win + Apache2 + XP Ad Astra answers 5 July 17th, 2005 05:02 AM