$ext = substr ($img, Strrpos ($img, '. ') +1)//Here is the code to read the file name extension
Get file name extension method two
$ext = End (Explode ('. ', $img));
Get file name extension method Three this is supposed to be the safest, is to use PHP $_files[' type '
$ext = $_files[' file ' [' type '];
Get file name extension method four
$ext = getimagesize ($img);//This function returns an array
if (!in_array ($ext, $array)) { Exit (' Thumbnail address error, please upload again! '); } Else { Echo (' Your uploaded file type is not allowed '); Exit; }
/* function Resolution: Array Array This does not say strtolower characters to lowercase substr character interception, the Chinese processing is not friendly. Strrpos The position where the character appears in the specified string explode split function, return result array End read Data last value $_files global variable file upload getimagesize Get the type of picture In_array Determines if the variable is in an array exit terminates the current script run
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.