473,463 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Move & Rename file to new directory

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
Jun 30 '09 #1
4 5248
Dormilich
8,658 Expert Mod 8TB
copy()

rename()

would be the obvious thing to try first.
Jun 30 '09 #2
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.
Jun 30 '09 #3
dlite922
1,584 Expert 1GB
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
Jun 30 '09 #4
Would this work to define the uploaded files' name

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

?
Jun 30 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Stéphane Ninin | last post by:
Hello world, I am fighting with what is probably a stupid problem. In a wxpython GUI, here is a method which must read a file, and if the file is not correctly formed rename it and create a...
1
by: rv | last post by:
I am developing an ASP.NET website with C#, VS 2003 and Framework 1.1. For some reason every time I execute a Directory.Move command, the next command takes 10-20 seconds to execute. Has anyone...
1
by: Tony | last post by:
I'm porting an old Coldfusion based content and asset management system to ASP.NET (and oh, how good it feels to write REAL code again - was a C++ hack for 10 years, started doing coldfusion about...
1
by: Matthew Eno | last post by:
I have a problem where I'm developing some code that moves files from one place to another (on the same drive) with the destination file having a new name. What's happening is that the line of...
5
by: Tony Meyer | last post by:
On Windows, if I do os.rename(old, new) where old is a file that is in-use (e.g. python itself, or a dll that is loaded), I would expect that an error would be raised (e.g. as when os.remove is...
3
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
4
by: jodleren | last post by:
While reading php.net I found " bool copy ( string $source , string $dest ) Makes a copy of the file source to dest . If you wish to move a file, use the rename() function. " ..... what?...
0
by: Matt MacDonald | last post by:
Hi all, I'm having a really frustrating problem. I have a web application that needs to modify the directory structure of the underlying files. The problem I'm having is that after the system...
3
by: robboll | last post by:
I am working on a form where one of the checkboxes asks if there is a document associated with the record? If you user clicks to check it (i.e., "Yes"), I would like these events to occur: 1. ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.