Jump to content


Photo

Files with the same name


  • Please log in to reply
1 reply to this topic

#1 Silver

Silver
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 26 April 2003 - 02:29 PM

I\'m making a script which involves people uploading files. Each person will be uploading a file and a picture of the file. Now, if someone comes to upload their file but there\'s already a file with the same name uploaded it mustn\'t be allowed to overwrite.

What I need it to do is for the database to automatically allocate an id number or something to the picture and a seperate one for the file, so if a file or picture of the same name is uploaded it would prevent them clashing.

The only thing I can think of which may be a problem is the files will be being downloaded, so the original name they were uploaded as (eg Amber.pet) must be restored when they\'re downloaded.

Hopefully that made sense! Please explain in a simple way as I\'m still quite a newbie to php :)

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 29 April 2003 - 05:06 AM

you can use the file_exists function to check for an existing file, and if so, change the name.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users