file upload to more than one directory

I’m trying to upload multiple files from a form to more than one directory using a single form and the same page as the action. for example:

Product type A
path_a/file1
path_a/file2

Product type B
path_b/file1
path_b/file2

Product type C
path_c/file1
path_c/file2

(there may be more than 2 files uploaded for each product type)

Below is what I’m using so far to upload to a single directory.

File:
File:
File:
<?php $destpath = "this is the path I want to upload to based on product type/" ; error_reporting(0); while(list($key,$value) = each($_FILES["file"]["name"])) { if(!empty($value)){ if ($_FILES["file"]["error"][$key] > 0) { echo "Error: " . $_FILES["file"]["error"][$key] . "
" ; } else { $source = $_FILES["file"]["tmp_name"][$key] ; $filename = $_FILES["file"]["name"][$key] ; move_uploaded_file($source, $destpath . $filename) ; echo "Uploaded: " . $destpath . $filename . "
" ; } } } ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service