Home > Backend Development > PHP Tutorial > PHP general detection function set (4)_PHP tutorial

PHP general detection function set (4)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:19:55
Original
892 people have browsed it

// Function name: CheckExtendName($C_filename,$A_extend)
// Function: Determine the extension of the uploaded file
// Parameters: $C_filename Uploaded file name
// $A_extend required extension
// Return value: Boolean value
// Remarks: None
//-------------------------- -------------------------------------------------- ------
-------
function CheckExtendName($C_filename,$A_extend)
{
if(strlen(trim($C_filename)) < 5)
{
return 0; //Returning 0 means no picture has been uploaded
}
$lastdot = strrpos($C_filename, "."); //Retrieve the last appearing position
$extended = substr($C_filename, $lastdot+1); //Get the extension

for($i=0;$i{
if (trim(strtolower($extended)) == trim(strtolower($A_extend[$i]))) //Convert uppercase
to lowercase and detect
{
$flag=1; //Add success flag
$i=count($A_extend); //Stop detection if detected
}
}

if($flag<>1)
{
for($j=0;$j{
$alarm .= $A_extend[$j] ." ";
}
AlertExit (Only .$alarm. files can be uploaded! And you are uploading files of type .$extended.);
return -1; //Return -1 to indicate uploading The type of image does not match
}

return 1; //Returning 1 means that the type of image meets the requirements
}
//-------------------------- -------------------------------------------------- ------------------
-------


//---------- -------------------------------------------------- -----------------------
-------
// Function name: CheckImageSize($ImageFileName,$LimitSize)
// Function: Check the size of the uploaded image
// Parameters: $ImageFileName Uploaded image name
// $LimitSize Required size
// Return value: Boolean value
// Remarks :None
//--------------------------------------------- ----------------------------------------
-------
function CheckImageSize($ImageFileName,$LimitSize)
{
$size=GetImageSize($ImageFileName);
if ($size[0]>$LimitSize[0] ││ $size[ 1]>$LimitSize[1])
{
AlertExit(image size is too large);
return false;
}
return true;
}
// -------------------------------------------------- ----------------------------------
-------


//--------------------------------------------- -------------------------------------
------
// Function name: Alert($C_alert,$I_goback=0)
// Function: Illegal operation warning
// Parameter: $C_alert (error message prompted)
// $I_goback (return to That page)
// Return value: String
// Remarks: None
//----------------------- -------------------------------------------------- ----------
-------
function Alert($C_alert,$I_goback=0)
{
if($I_goback<>0)
{
echo "<script>alert($C_alert);history.go($I_goback);</script>";
}
else
{
echo "<script>alert($C_alert);</script>";
}
}
//------------------ -------------------------------------------------- ---------------
-------


//-------------- -------------------------------------------------- ------------------
-------
//----------------- -------------------------------------------------- ----------------
-------

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532629.htmlTechArticle// Function name: CheckExtendName($C_filename,$A_extend) // Function: Determine the extension of the uploaded file/ / Parameter: $C_filename Uploaded file name // $A_extend required extension // Return...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template