먼저 업로드 된 이미지 형식을 확인하십시오.
$valid_formats = array("jpg", "png", "gif", "bmp" , "jpeg");
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
if (strlen($name)) {
list($txt, $ext) = explode(".", $name);
if (in_array($ext, $valid_formats)) {
if ($size < (10240 * 10240)) {
$actual_image_name = time() . substr(str_replace(" ", "_", $txt), 5) . "." . $ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if (move_uploaded_file($tmp, $path . $actual_image_name)) {
//mysql_query("INSERT into hw_site_gallery SET gallery_content='$actual_image_name' ,hotel_id='$hotel_id', gallery_type='$gallery_type'");
/* QUERY END's HERE */
}
else
echo "failed";
}
else
echo "Image file size max 10 MB";
}
else
echo "Invalid file format..";
}
비록 내가 당신의 고통을 느끼지만, 이것은 광범위하고 의견에 기반한 방법입니다. – jterry