From 9d68c0f9eaee54d1d2952b7c1eb1919f785b24b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AA=9B=E5=A6=82?= <1271678381@qq.com> Date: Sun, 22 May 2022 21:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...07\344\273\266\344\270\212\344\274\240.md" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "\345\220\264\345\252\233\345\246\202/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" diff --git "a/\345\220\264\345\252\233\345\246\202/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" "b/\345\220\264\345\252\233\345\246\202/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" new file mode 100644 index 0000000..73c42fe --- /dev/null +++ "b/\345\220\264\345\252\233\345\246\202/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" @@ -0,0 +1,49 @@ +# 作业 + +1、 实现一个文件上传,限制只能上传pdf和word格式,大小为1M以内。 + +```php + + + + + Title + + + +
+ 请上传一个文件: + +
+ +
+ + +``` + + + +```php +SIZE){ + echo "上传文件太大了!"; + }else{ + echo "上传文件太小了!"; + } + $array = array("pdf","docx"); + $name = $_FILES['file']['submit']; + $nameArr = expllode("".",$name"); + $lastname = $nameArr[count($nameArr)-1]; + $result = array_search($lastname,$array); + if ($result===false){ + echo "上传文件格式错误!"; + }else{ + echo "上传文件格式正确";} +} +``` + -- Gitee