moving a existing file from one folder to another

This is a discussion on moving a existing file from one folder to another within the PHP Language forums, part of the PHP Programming Forums category; Lets say i have a file with the name atest.doc and its in the directory www/directory1 but i ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-13-2006
Realtime
 
Posts: n/a
Default moving a existing file from one folder to another



Lets say i have a file with the name atest.doc and its in the directory www/directory1
but i want to move that file using php to www/directory2/ how do i do this
i tried

move_uploaded_file() but it didn't work any ideas?


Thanks...



Reply With Quote
  #2 (permalink)  
Old 04-13-2006
Chung Leong
 
Posts: n/a
Default Re: moving a existing file from one folder to another

You need rename(), I believe.

Reply With Quote
  #3 (permalink)  
Old 04-13-2006
Jerry Stuckle
 
Posts: n/a
Default Re: moving a existing file from one folder to another

Realtime wrote:
>
>
> Lets say i have a file with the name atest.doc and its in the directory
> www/directory1 but i want to move that file using php to
> www/directory2/ how do i do this i tried
>
> move_uploaded_file() but it didn't work any ideas?
>
>
> Thanks...
>
>
>


Do it with telnet (ssh) or ftp.

The file wasn't (just) uploaded, so you can't move it with move_uploaded_file().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #4 (permalink)  
Old 04-13-2006
fletch
 
Posts: n/a
Default Re: moving a existing file from one folder to another

Coul also use link() and unlink()

Reply With Quote
  #5 (permalink)  
Old 04-13-2006
Good Man
 
Posts: n/a
Default Re: moving a existing file from one folder to another

"Chung Leong" <chernyshevsky@hotmail.com> wrote in
news:1144902014.393228.323980@u72g2000cwu.googlegr oups.com:

> You need rename(), I believe.


keep in mind that rename() is useless on windows boxes:
http://ca3.php.net/manual/en/function.rename.php#59570

Reply With Quote
  #6 (permalink)  
Old 04-14-2006
Chung Leong
 
Posts: n/a
Default Re: moving a existing file from one folder to another


Good Man wrote:
> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
> news:1144902014.393228.323980@u72g2000cwu.googlegr oups.com:
>
> > You need rename(), I believe.

>
> keep in mind that rename() is useless on windows boxes:
> http://ca3.php.net/manual/en/function.rename.php#59570


Have you tested this yourself? I haven't seen anything of the sort
described. Rename worked as it should (on WinXP).

Reply With Quote
  #7 (permalink)  
Old 04-18-2006
Good Man
 
Posts: n/a
Default Re: moving a existing file from one folder to another

"Chung Leong" <chernyshevsky@hotmail.com> wrote in
news:1144971325.768368.59470@g10g2000cwb.googlegro ups.com:

>
> Good Man wrote:
>> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
>> news:1144902014.393228.323980@u72g2000cwu.googlegr oups.com:
>>
>> > You need rename(), I believe.

>>
>> keep in mind that rename() is useless on windows boxes:
>> http://ca3.php.net/manual/en/function.rename.php#59570

>
> Have you tested this yourself? I haven't seen anything of the sort
> described. Rename worked as it should (on WinXP).


hi

yes, sorry, that comment refers to renaming FOLDERS as useless/totally
buggy on windows; renaming files works properly.

Reply With Quote
  #8 (permalink)  
Old 04-18-2006
Chung Leong
 
Posts: n/a
Default Re: moving a existing file from one folder to another


Good Man wrote:
> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
> news:1144971325.768368.59470@g10g2000cwb.googlegro ups.com:
>
> >
> > Good Man wrote:
> >> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
> >> news:1144902014.393228.323980@u72g2000cwu.googlegr oups.com:
> >>
> >> > You need rename(), I believe.
> >>
> >> keep in mind that rename() is useless on windows boxes:
> >> http://ca3.php.net/manual/en/function.rename.php#59570

> >
> > Have you tested this yourself? I haven't seen anything of the sort
> > described. Rename worked as it should (on WinXP).

>
> hi
>
> yes, sorry, that comment refers to renaming FOLDERS as useless/totally
> buggy on windows; renaming files works properly.


Renaming folders works too.

Reply With Quote
  #9 (permalink)  
Old 04-18-2006
Good Man
 
Posts: n/a
Default Re: moving a existing file from one folder to another

"Chung Leong" <chernyshevsky@hotmail.com> wrote in
news:1145385967.253288.226700@i39g2000cwa.googlegr oups.com:

>> >> > You need rename(), I believe.
>> >>
>> >> keep in mind that rename() is useless on windows boxes:
>> >> http://ca3.php.net/manual/en/function.rename.php#59570
>> >
>> > Have you tested this yourself? I haven't seen anything of the sort
>> > described. Rename worked as it should (on WinXP).

>>
>>
>> yes, sorry, that comment refers to renaming FOLDERS as useless/totally
>> buggy on windows; renaming files works properly.

>
> Renaming folders works too.


ahhh, but read the note. Yes, the folders are sort of 'renamed' - but did
you compare the contents of your 'renamed' folder to the 'original'
folder?:

"If you're trying to rename a directory, files within the directory will
NOT be present in the renamed directory, though sub-directories WILL be
present. Ultra-strange. And as noted, your 'old' directory will remain on
the server totally intact, which can be very confusing."

confirm?



Reply With Quote
  #10 (permalink)  
Old 04-19-2006
Chung Leong
 
Posts: n/a
Default Re: moving a existing file from one folder to another

Good Man wrote:
> ahhh, but read the note. Yes, the folders are sort of 'renamed' - but did
> you compare the contents of your 'renamed' folder to the 'original'
> folder?:
>
> "If you're trying to rename a directory, files within the directory will
> NOT be present in the renamed directory, though sub-directories WILL be
> present. Ultra-strange. And as noted, your 'old' directory will remain on
> the server totally intact, which can be very confusing."
>
> confirm?


Yes, it works as it's supposed to. Go test it yourself.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:06 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0