时间:2021-07-01 10:21:17 帮助过:4人阅读
这段代码用于上传图片,可以根据图片类型检测图片是否安全,不是简单的检测扩展名
<?php // upload.php echo <<<_ENDPHP Form Upload _END; if ($_FILES) { https://www.gxlcms.com/$name = $_FILES['filename']['name']; switch($_FILES['filename']['type']) { case 'image/jpeg': $ext = 'jpg'; break; case 'image/gif': $ext = 'gif'; break; case 'image/png': $ext = 'png'; break; case 'image/tiff': $ext = 'tif'; break; default: $ext = ''; break; } if ($ext) { https://www.gxlcms.com/$n = "image.$ext"; move_uploaded_file($_FILES['filename']['tmp_name'], https://www.gxlcms.com/$n); echo "Uploaded image 'https://www.gxlcms.com/$name' as 'https://www.gxlcms.com/$n':
"; echo ""; } else echo "'https://www.gxlcms.com/$name' is not an accepted image file"; } else echo "No image has been uploaded"; echo ""; ?>
希望本文所述对大家的php程序设计有所帮助。