Home  >  Article  >  Backend Development  >  PHP perfect ereg verification file upload_PHP tutorial

PHP perfect ereg verification file upload_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:23890browse

ereg(regular expression, string, [match part of array name]);
For more details, please see: http://www.bkjia.com/phper/18/2a94e504e94424a7a461342d049c0018.htm
This program uses ereg to verify whether the file type and file name uploaded by the user comply with the file naming rules.
*/

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();

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445369.htmlTechArticleereg(regular expression, string, [match partial array name]); For more details, please see: http://www.bkjia.com/phper/18/2a94e504e94424a7a461342d049c0018.htm This program uses ereg to verify...
Statement:
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