Re: Re: file upload question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i add me to the question.

2009/8/3 Peter Ford <pete@xxxxxxxxxxxxx>

> seb wrote:
> > Hey all,
> >
> > i am using move_upload function to upload files to the server, but i
> > want to add a feature that will allow files to be archived that have
> > been uploaded already.
> >
> > so, the problem is:
> >
> > i upload a file that i want to "upgrade" and move the old file to an
> > archive directory but I want to verify the NEW file is upload BEFORE
> > moving the old file (the file being uploaded might not have the same
> > filename as the old file currently on the server)..
> >
> > i want to move the old file only when the new file was successfully
> > uploaded. something like:
> >
> > if(move_uploaded_file(....))
> > {
> >        rename(...);
> > }
> >
> > only one problem.. then if both files have the same name it will be
> > overwritten before it moves the old one i want to save. if i move the
> > old one first, there still the possibility of the new upload failing so
> > i am back to square one..
> >
> > i guess i can move_upload to a different directory, verify it's been
> > uploaded, move the old to the archive file, then move the new file back
> > to where it should be (where the archive file was)..
> >
> > is that my only option? any suggestions?
>
> I'd suggest you *copy* the old file (if it exists) to archive anyway, and
> then
> *move* it back if the new version doesn't verify. That seems pretty safe to
> me...
>
> --
> Peter Ford                              phone: 01580 893333
> Developer                               fax:   01580 893399
> Justcroft International Ltd., Staplehurst, Kent
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux