Php universal function set (4 ). Function name: CheckExtendName ($ C_filename, $ A_extend) function: parameter for determining the extension of the file to be uploaded: $ C_filename indicates the name of the file to be uploaded. the name of the extension required by $ A_extend is returned. // Function name: checkExtendName ($ C_filename, $ A_extend)
// Usage: determine the extension of the uploaded file
// Parameter: $ C_filename: name of the uploaded file
// $ A_extend required extension
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckExtendName ($ C_filename, $ A_extend)
{
If (strlen (trim ($ C_filename) <5)
{
Return 0; // if 0 is returned, the image is not uploaded.
}
$ Lastdot = strrpos ($ C_filename, "."); // retrieves the last position that appears.
$ Extended = substr ($ C_filename, $ lastdot + 1); // Retrieve the extension
For ($ I = 0; $ I {
If (trim (strtolower ($ extended) = trim (strtolower ($ A_extend [$ I]) // Large conversion
Lowercase and detection
{
$ Flag = 1; // add a success flag
$ I = count ($ A_extend); // if it is detected, the detection is stopped.
}
}
If ($ flag <> 1)
{
For ($ j = 0; $ j {
$ Alarm. = $ A_extend [$ j]. "";
}
AlertExit (only. $ alarm. file can be uploaded! And you uploaded a. $ extended. type file );
Return-1; // return-1 indicates the type of the uploaded image does not match
}
Return 1; // return 1 indicates that the image type meets the requirements.
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckImageSize ($ ImageFileName, $ LimitSize)
// Usage: check the size of the uploaded image
// Parameter: name of the image uploaded by $ ImageFileName
// The size required by $ LimitSize
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckImageSize ($ ImageFileName, $ LimitSize)
{
$ Size = GetImageSize ($ ImageFileName );
If ($ size [0]> $ LimitSize [0] │ $ size [1]> $ LimitSize [1])
{
AlertExit (the image size is too large );
Return false;
}
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: Alert ($ C_alert, $ I _goback = 0)
// Usage: illegal operation warning
// Parameter: $ C_alert (error message)
// $ I _goback (return to that page)
// Return value: string
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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 ";
}
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
Http://www.bkjia.com/PHPjc/532629.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532629.htmlTechArticle// function name: CheckExtendName ($ C_filename, $ A_extend) // used for: File Upload extension judgment // parameter number: $ C_filename: the file name to be uploaded // The extension required by $ A_extend // return...