PHP perfect ereg verification file upload_PHP tutorial

WBOY
Release: 2016-07-20 11:02:23
Original
846 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!