Image

Imagegaimung wrote in Imagephp

Okay. I have an idea for an upload script. I had a rough sketch of it but need help putting ideas together since I'm such a newbie that I can only think of what might work.

So here's the idea.

Use the copy() function which last time I checked, was a built in PHP function. So then I was using it like this:

copy($theFile,"directorygoeshere");

unlink($theFile);


$theFile value will come from the form. Of course.

Then I want to be able to choose my directory from a list of directory which will assumably be given in the script. Here is the idea I had in mind"



Okay before we get to the code, I think I should do some explaining about what the form will look like. So uh, we have our basic form. One to select the file ($theFile), one to select the directory ($dirselect) and then the submit button.

So I was going to define the directories inside the script. An example:


$dir1="/music"
$dir2="/images"
$dir3="/docs"


Then I wanted to use switch() to say if $dirselect=$dir1 then upload it here. To me, this makes sense. Here is a sample code of what I'm thinking of.

switch ($dirselect)
{
case music
copy ($thefile, $dir1);
echo "file has been uploaded";
break;

case pictures:
copy ($thefile, $dir2);
echo "file has been uploaded";
break;

case documents
copy ($thefile, $dir3);echo "file has been uploaded";
break;
}

Somehow I got a permissions error. Anyone know why? The directories were all chmoded to 777. Any help would be greatly appreciated assuming you all understand the stuff I just wrote. Anyways, help = appreciated. =)