if (isset($_POST['addProductAttributeTypeButton'])){ $patv->saveNewProductAttributeType($_POST['product_attribute_type'],$_FILES['product_artwork_template']); } // ********** different file ***************** function saveNewProductAttributeType($product_attribute_type,$product_attribute_type_artwork_template){ include_once("classes/ProductAttributeType.class.php"); if (!strlen($product_attribute_type['name'])>0) $errors[] = 'Product name not set'; if (isset($product_attribute_type['is_artwork'])){ if (!strlen($product_attribute_type['width'])>0) $errors[] = 'Product width not set'; if (!strlen($product_attribute_type['height'])>0) $errors[] = 'Product height not set'; if (!strlen($product_attribute_type['dpi'])>0) $errors[] = 'Product dpi not set'; if (!isset($product_attribute_type_artwork_template)) $errors[] = 'Artwork template file not uploaded.'; else { try{ fileUploadErrorCheck($product_attribute_type_artwork_template); } catch (Exception $e){ $errors[] = $e->getMessage(); } } } // ........... other code ............. } function fileUploadErrorCheck($file){ switch ($file['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_INI_SIZE: echo "bugger ini size"; throw new Exception("The uploaded file exceeds the upload_max_filesize directive (".ini_get("upload_max_filesize").") in php.ini."); break; case UPLOAD_ERR_FORM_SIZE: echo "max file size"; throw new Exception("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."); break; case UPLOAD_ERR_PARTIAL: throw new Exception("The uploaded file was only partially uploaded."); break; case UPLOAD_ERR_NO_FILE: throw new Exception("No file was uploaded."); break; case UPLOAD_ERR_NO_TMP_DIR: throw new Exception("Missing a temporary folder."); break; case UPLOAD_ERR_CANT_WRITE: throw new Exception("Failed to write file to disk"); break; default: throw new Exception("Unknown File Error"); } }