I am making a program that lets users upload files to certain directories based on the certain option they pick. I want directories to be made automatically before the person even picks where they want the images to go. I did this as follows. *description firstπ$project_id specifies the MAIN folder--inputted by user-- and the corrosponding $sectiondir's are the subdirectory of the file which are chosen in the form select. There are 7 formselects. New Subdirectories are made for each Project ID directory. Bare with me, heh. π
<?php
$project_dir = $_POST['project_dir'];
function make_default_dirs() {
global $project_dir;
//create dirs
mkdir("$project_dir/$sectiondir1/", 0755);
chmod("$project_dir/$sectiondir1/", 0777);
mkdir("$project_dir/$sectiondir2/", 0755);
chmod("$project_dir/$sectiondir2/", 0777);
mkdir("$project_dir/$sectiondir3/", 0755);
chmod("$project_dir/$sectiondir3/", 0777);
mkdir("$project_dir/$sectiondir4/", 0755);
chmod("$project_dir/$sectiondir4/", 0777);
mkdir("$project_dir/$sectiondir5/", 0755);
chmod("$project_dir/$sectiondir5/", 0777);
mkdir("$project_dir/$sectiondir6/", 0755);
chmod("$project_dir/$sectiondir6/", 0777);
mkdir("$project_dir/$sectiondir7/", 0755);
chmod("$project_dir/$sectiondir7/", 0777);
}
if (!empty($_POST['project_dir']) ) {
//check if main dir is available then makes if if it is not.
mkdir("$project_dir/", 0755);
chmod("$project_dir/", 0777);
} else {
print "Project photos\' directory not created";
}
if (is_dir("$project_dir/") && !empty($_POST['project_dir']) ) {
make_default_dirs();//execute function
} else {
print "Please Enter a project id.";
}
?>
That was the easy part understanding the creating of the directories.π
Now I would like to use a form select to specify which sectiondir it goes in but I dont want to have to use the hardcoded thing that I had above. 1 of the 7 form selects is as follows:
<select size="1" name="sectiondir1">
<OPTION>-----Section-----
<OPTION VALUE="electricalpanel">Electrical Panel
<OPTION VALUE="contactor">Contactor Box
<OPTION VALUE="elements">Elements
<OPTION VALUE="steamtablewp">Steam Table Water Pans
<OPTION VALUE="steamcabwp">Steam Cabinet Water Pans
<OPTION VALUE="steamcabd">Steam Cabinet Doors
<OPTION VALUE="steamcabmod">Steam Cabinet Module
<OPTION VALUE="steamcabhe">Steam Cabinet Hood/Exhaust
<OPTION VALUE="producebin">Produce Bin
<OPTION VALUE="reachfridge">Reach in Refridgerator
<OPTION VALUE="panfillsys">Water Pan Water Fill System
<OPTION VALUE="steamtablecont">Steam Table Controller
<OPTION VALUE="tacowarmunit">Taco Warmer Unit/Taco Tower
<OPTION VALUE="cheesemelter">Round Up Cheese Melters
<OPTION VALUE="integrity">Structural Integrity
<OPTION VALUE="misc">Miscellaneous
<OPTION VALUE="summary">Summary/Recommendation
</select>
Is it possible to have arrays that I can use to choose which directory the image file goes by using the form select? I cant seem to find out how to do this anywhere.
Thanks a lot,
-Steve