How to safely upload images in PHP,
This article describes the way PHP securely uploads images. Share to everyone for your reference. The specific analysis is as follows:
This code is used to upload images, you can detect the image according to the type of image is safe, not a simple detection extension
<?php//Upload.phpecho <<<_endPHP Form Upload_end;if ($_files) {$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) {$n = "image. $ext"; Move_uploaded_file ($_files[' filename '] [' tmp_name '], $n); echo "uploaded image ' $name ' as ' $ N ':
"; echo" ";} else echo "' $name ' is a accepted image file";} else echo "No image has been uploaded"; echo ";? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/970976.html www.bkjia.com true http://www.bkjia.com/PHPjc/970976.html techarticle php Safe Upload image method, this article describes the PHP safe upload image method. Share to everyone for your reference. The specific analysis is as follows: This code is used to upload images, you can ...