Jump to content


Overwriting an existing file when uploading...


4 replies to this topic

#1 Bug

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 3,611 posts
  • Gender:Male
  • Location:Perth, Australia

Posted 09 August 2006 - 07:03 AM

Hey guys, I would just like to know something... like I know how to write a script that lets you upload files to the net... but how do you go about it if you want to update a file, meaning you have to overwrite it when you upload it again...

I'm still getting used to PHP so yeah... any help would be greatly appreciated.

Thanks,
Joshua

#2 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 09 August 2006 - 09:53 AM

One way is that you can delete it first.
if(file_exists( $yourFile ))
{
  unlink( $yourFile );
}
move_uploaded_file( ... );


#3 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 09 August 2006 - 12:23 PM

I think it will automatically overwrite the file if you don't have checks for file_exists.

#4 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 09 August 2006 - 10:04 PM

View PostDemonslay, on Aug 9 2006, 05:23 PM, said:

I think...
i know :)

#5 Bug

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 3,611 posts
  • Gender:Male
  • Location:Perth, Australia

Posted 26 August 2006 - 08:13 AM

Yeah, thanks... it worked great for me!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users