Current location: Hot Scripts Forums » Programming Languages » PHP » Rename/Copy File to new dir


Rename/Copy File to new dir

Reply
  #1 (permalink)  
Old 04-24-07, 04:17 PM
samot samot is offline
Newbie Coder
 
Join Date: Apr 2007
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Rename/Copy File to new dir

Hello,
I'm trying to move a file from one dir to another dir. When I move a single file from directory "X" into directory "Y", it does not copy. But it updates into the db perfectly. Then, when I moved the file from dir "Y" into dir "X", it actually copy over into dir "Y".

I need help please. Here are the codes:
PHP Code:



readdir
(opendir($row['dir']));
copy($row['path'] . "/" $row['file'], $row['newpath'] . "/" $row['file'])                    
closedir(opendir($row['dir'])); 
I only need one file from the current directory move to a new diretory.
Thanks,
Samot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-24-07, 04:25 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Use rename() instead.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-24-07, 04:38 PM
samot samot is offline
Newbie Coder
 
Join Date: Apr 2007
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
I tried rename(). Everything in the db updated...and dir path is updated from "X" to "Y". But the file in the folder directory "X" does not move to the folder directory "Y".

Since it is updated the dir path in the db...when I moved the file from "Y" back into "X"...then the file appeared in the "Y" folder.

I hope I don't am clear to the readers.
samot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking a file exists lee PHP 3 04-23-06 01:44 AM
Last Uploaded File in a Dir qtarantino Script Requests 0 03-29-06 12:30 PM
Error message not getting displayed. sanjeet Windows .NET Programming 0 12-20-05 11:48 AM
Dir showing as file jack_mcs PHP 4 10-11-04 07:48 PM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 04:09 PM


All times are GMT -5. The time now is 05:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.