This article mainly introduces how php uses ereg to verify File Upload. It is a simple and practical Regular Expression verification technique and has some reference value. If you need it, you can refer
This article mainly introduces how php uses ereg to verify File Upload. It is a simple and practical Regular Expression verification technique and has some reference value. If you need it, you can refer
This example describes how php uses ereg to verify file upload. Share it with you for your reference. The specific analysis is as follows:
The ereg format is as follows:
The Code is as follows:
Ereg (Regular Expression, String, [matching partial array names]);
Here, ereg is used to verify whether the file type and file name uploaded by the user comply with the file naming rules. The instance code is as follows:
The Code is as follows:
If (! Is_uploaded_file ($ upfile ))
{
Echo ("You have not uploaded anything! ");
Exit ();
}
Else
{
If (! Ereg (". (htm | html) $", $ upfile_name ))
{
Echo ("dedecms template can only use. htm or. html extension! ");
Exit ();
}
If (ereg ("[/]", $ upfile_name ))
{
Echo ("the template file name contains invalid characters. Upload prohibited! -1 ");
Exit ();
}
Move_uploaded_file ($ upfile, $ templetdird. '/'. $ upfile_name );
@ Unlink ($ upfile );
Echo ("a file is uploaded successfully! ");
Exit ();
}
Exit ();
I hope this article will help you with PHP programming.
,