I'm uploading an image, but I want it to go to two different folders, in one folder the image will be the regular size which is 700 pixels wide and in the other folder will just be a thumbnail which will be 100 pixels.

I can get it to add the image to the database as well as upload it to the first folder, but I can't get it to upload to the thumbnail folder too.

This is what I've got, but I'm site sure where it's going wrong:
Code:
$style = (isset($_POST['style']) ? implode(' ', $_POST['style']) : '');
//create array to temporarily grab variables
$input_arr = array();
//grabs the $_POST variables and adds slashes
foreach ($_POST as $key => $input_arr) {
    $_POST[$key] = addslashes($input_arr);
}

// resizes an image to fit a given width in pixels.
// works with BMP, PNG, JPEG, and GIF
// $file is overwritten
function fit_image_file_to_width($file, $w, $mime = 'image/jpeg') {
    list($width, $height) = getimagesize($file);
    $newwidth = $w;
    $newheight = $w * $height / $width;

    switch ($mime) {
        case 'image/jpeg':
            $src = imagecreatefromjpeg($file);
            break;
        case 'image/png';
            $src = imagecreatefrompng($file);
            break;
        case 'image/bmp';
            $src = imagecreatefromwbmp($file);
            break;
        case 'image/gif';
            $src = imagecreatefromgif($file);
            break;
    }

    $dst = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    switch ($mime) {
        case 'image/jpeg':
            imagejpeg($dst, $file);
            break;
        case 'image/png';
            imagealphablending($dst, false);
            imagesavealpha($dst, true);
            imagepng($dst, $file);
            break;
        case 'image/bmp';
            imagewbmp($dst, $file);
            break;
        case 'image/gif';
            imagegif($dst, $file);
            break;
    }

    imagedestroy($dst);
}

// init file vars
$pic  = $_FILES['photo']['name'];
$target = '/uploads/image/filename/thumb/' . basename( $_FILES['photo']['name']);
$temp_name = $_FILES['photo']['tmp_name'];
$type = $_FILES["photo"]["type"];
$pic2  = $_FILES['photo']['name'];
$target2 = '/uploads/image/filename/thumb/thumbnailbig/' . basename( $_FILES['photo']['name']);
$temp_name2 = $_FILES['photo']['tmp_name'];
$type2 = $_FILES["photo"]["type"];

// Connects to your Database
mysql_connect($host,$username,$password) or die(mysql_error()) ;
mysql_select_db($database) or die(mysql_error()) ;

// get form data
$class = $_POST['class'];
$foreign_id = $_POST['foreign_id'];
$name = mysql_real_escape_string(isset($_POST['name']) ? $_POST['name'] : 'No name');
$order = $_POST['order'];

//Writes the information to the database
mysql_query("INSERT INTO `images` (`id`, `class`, `foreign_id`, `title`, `filename`, `created`, `modified`, `order`, `category`) VALUES (NULL, '$_POST[class]', '$_POST[foreign_id]', '$_POST[name]', '$pic', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '$_POST[order]', '$style')");

// resize the image in the tmp directorys
fit_image_file_to_width($temp_name, 700, $type);
fit_image_file_to_width($temp_name2, 100, $type2);

//Writes the photo to the server
if(move_uploaded_file($temp_name, $target))
if(move_uploaded_file($temp_name2, $target2))