View Single Post
Old 07-01-2007, 5:09 PM   #4
Nikolai Chuvakhin
 
Nikolai Chuvakhin's Avatar
 
Posts: n/a
My Photos: ()

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Upload in different directories

"Volhouden" <vraag@maar.nl> wrote in message
news:<Hm6%a.109093$0W5.2955388@pollux.casema.net>. ..
>
> I search on the internet and i saw a lot of upload-scripts. But in all you
> only can give 1 directory to put your pictures (or other files) in.
>
> On my site i have 3 different driectories. (example: football, swimming and
> tennis). And i only want to have 1 upload-pae with a <option> where i can
> choose the directory.
>
> Does anyone have a script for this?


Take the script you are currently using and make two modifications
to it:

1. Add a SELECT control insode the HTML form:

<SELECT name="destination">
<OPTION value="f">Football
<OPTION value="s">Swimming
<OPTION value="t">Tennis
</SELECT>

2. Find the move_uploaded_file() function. It should look something
like this:

move_uploaded_file ($file, '/destination/directory');

The first argument is the temporary name of the uploaded file,
so you shouldn't modify it. Now edit this line slightly and
add a few lines before it:

switch ($_POST['destination']) {
case 'f':
$dest = '/football';
break;
case 's':
$dest = '/swimming';
break;
case 't':
$dest = '/tennis';
break;
}
move_uploaded_file ($file, $dest);

That's it, really...

Cheers,
NC
  Reply With Quote