Page 1 of 1
Question about.....thinge :P
Posted: Thu Jul 11, 2002 3:36 pm
by qads
hi,
i want to offer a service at my site which will allow users to submit their own work, what would be the best way to do that?
allow uploads?
have the email the code etc?
or something else?
by the way, how i can i make sure that no files are over writen when i use a upload script?
thanks for your time
- Qads
Posted: Thu Jul 11, 2002 3:40 pm
by llimllib
Definitely you want uploads, and you should call file_exists() before you write to any directory. If a file already exists in the directory, append a random number to the end of the file name, check that it exists again, and when it doesn't, insert it into the directory.
Posted: Thu Jul 11, 2002 4:03 pm
by hob_goblin
Code: Select all
$filename = "foo.txt";
$farray = explode(".", $filename);
$name = $farrayї0];
$ext = $farrayї1];
if(!file_exists($filename)){
//make it
} else {
$i = 0;
while(file_exists($name.$i.$ext)){
$i++
}
//make "$name.$i.$ext"
Posted: Thu Jul 11, 2002 4:04 pm
by hob_goblin
bah, that would need to be edited, incase the filename had more than one period in it..
Posted: Thu Jul 11, 2002 4:47 pm
by qads
hmm, i could use a system like hot scripts.com which only keeps the info on scripts (e.g. what they are and where they are), this way i will not only save on the space but also it will sto the renameing problem
thanks alot guys for this help,
- Qads