php uses ereg to verify file upload method,
The example in this article describes how PHP uses ereg to verify file upload. Share it with everyone for your reference. The specific analysis is as follows:
ereg format is as follows:
Copy code The code is as follows:
ereg(regular expression, string, [match partial array name]);
Here, ereg is used to verify whether the file type and file name uploaded by the user comply with the file naming rules. The example code is as follows:
Copy code The code is as follows:
if( !is_uploaded_file($upfile) )
{
echo("You didn't upload 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 illegal characters and is prohibited from uploading! -1");
exit();
}
move_uploaded_file($upfile, $templetdird.'/'.$upfile_name);
@unlink($upfile);
echo("Successfully uploaded a file!");
exit();
}
exit();
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/928220.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/928220.htmlTechArticleHow to use ereg to verify file upload in php. This article describes how to use ereg to verify file upload in php. Share it with everyone for your reference. The specific analysis is as follows: The ereg format is as follows: ...