The Ereg format is as follows:
| The code is as follows |
Copy Code |
| Ereg (regular expression, string, [match part array name]); |
Here we use the Ereg to verify that the file types uploaded by the user and file names are in accordance with the file naming rules, and the instance code is as follows:
| code is as follows |
copy code |
if (!is_uploaded_file ($upfile))
{
Echo (" You did not upload anything! " ");
exit ();
}
else
{
if (!ereg (). htm|html) $ ", $upfile _name))
{
echo (dedecms template can only use. htm or. html extensions! ");
exit ();
}
if (Ereg ("[/]", $upfile _name))
{
echo ("template file name has illegal characters, prohibit uploading!") -1 ");
exit ();
}
Move_uploaded_file ($upfile, $templetdird. ' /'. $upfile _name);
@unlink ($upfile);
Echo ("Upload a file successfully!") ");
exit ();
}
exit (); |
Now we just talk about verifying the file name of the upload is legitimate, later tutorials we will continue to say how to determine whether the uploaded content is safe.