#/ Determine $m_type
 $m_type = '';
 if (is_uploaded_file(@$_FILES['m_file']['tmp_name'])) {
     $up_type = $_FILES['m_file']['type'];
     //var_dump($up_type); die();
     if (stristr($up_type, 'video') != false) {
         $m_type = 'video';
     } else {
         if (stristr($up_type, 'image') != false) {
             $m_type = 'image';
         }
     }
 }
 $placement_tag = $sql_prt = $sql_prt_2 = $new_m_file = '';
 if ($m_type == 'video') {
     $new_m_file = upload_vdo('m_file', $up_path, 'Media File', '', 'CUSA_ADMIN_MSG_GLOBAL');
 } else {
     if ($m_type == 'image') {
         $new_m_file = upload_img_rs('m_file', 0, 0, $up_path, 'Media File', '', '', 'CUSA_ADMIN_MSG_GLOBAL');
     }
 }
 if ($new_m_file != '') {
     $sql_prt .= " m_file='{$new_m_file}', ";
     $sql_prt_2 .= " m_type='{$m_type}', ";
     $placement_tag = current(explode(".", $new_m_file));
     $sql_prt .= " placement_tag='{$placement_tag}', ";
 }
 #-
 if ($med_id > 0) {
     ###/ Updating Database
     #/ site_media
/**
 * Function upload_img_rs_ar
 * PURPOSE: upload & resize images in array[]
 *
 * $field_name = Image field name
 * $img_width = width to resize to. set to '0' to prevent resize
 * $img_height = height to resize to. set to '0' to prevent resize
 * $up_loc = upload location for the image. Like '../img/clients'
 * $img_title = Image Title (mainly used for errors)
 * $insert_name_part = Insert Part in File Name (use to create different size images like thunbnail)
 * $fix_height = fix height as well
 * $images_only = upload and return info about Images Only from $_FILES
 * $copies = array with (insert_parts, size_w, size_h) to create copies [applicable on images only]
 *
 *
 * RETURNS: Array of new names
 *
 * [USAGE example]
 *  $new_p_files = $sql_part_2 = array();

    $copy_data = array(0=>array('i_part'=>'_small', 'size_w'=>300, 'size_h'=>300),
    1=>array('i_part'=>'_t', 'size_w'=>30, 'size_h'=>30));

    $new_p_files = upload_img_rs_ar('p_file', 0, 0, $up_path, 'Image', '', '', 'CUSAADMIN_MSG_GLOBAL', false, $copy_data);
    if(is_array($new_p_files) && count($new_p_files)>0)
    {
        for($i=0; $i<count($new_p_files); $i++)
        {
            if($new_p_files[$i]=='') continue;
            $sql_part_2[] = "('{$pf_id}', '{$new_p_files[$i]['new_name']}', '{$new_p_files[$i]['type']}')";
        }
    }
 *
*/
function upload_img_rs_ar($field_name, $img_width, $img_height, $up_loc, $img_title, $insert_name_part = '', $fix_height = '', $error_sess_name = 'CUSA_MSG_GLOBAL', $images_only = false, $copies = array())
{
    $rtn_ar = array();
    if (isset($_FILES[$field_name]) && @is_array($_FILES[$field_name]) && @is_array($_FILES[$field_name]['tmp_name'])) {
        for ($i = 0; $i < count($_FILES[$field_name]['tmp_name']); $i++) {
            //var_dump("<pre>", $_FILES[$field_name]['type'][$i]);
            if ($_FILES[$field_name]['tmp_name'][$i] == '') {
                $rtn_ar[$i] = '';
                continue;
            }
            #/ determine type
            $up_type = $_FILES[$field_name]['type'][$i];
            $m_type = '';
            if (stristr($up_type, 'video') != false) {
                $m_type = 'video';
            } else {
                if (stristr($up_type, 'image') != false) {
                    $m_type = 'image';
                }
            }
            #/ upload files
            $new_name = '';
            if ($m_type == 'video') {
                if ($images_only != false) {
                    continue;
                }
                $new_name = upload_vdo($field_name, $up_loc, $img_title, $insert_name_part, $error_sess_name, $i);
            } else {
                if ($m_type == 'image') {
                    $new_name = upload_img_rs($field_name, $img_width, $img_height, $up_loc, $img_title, $insert_name_part, $fix_height, $error_sess_name, $i, $copies);
                }
            }
            if (!empty($new_name)) {
                $rtn_ar[$i]['new_name'] = $new_name;
                $rtn_ar[$i]['type'] = $m_type;
            }
        }
    }
    return $rtn_ar;
}