Question about.....thinge :P

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Question about.....thinge :P

Post 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
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post 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.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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"
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

bah, that would need to be edited, incase the filename had more than one period in it..
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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 :P

thanks alot guys for this help,

- Qads
Post Reply