您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

怎么样限制上传图片的格式呢?

2024/3/23 20:52:35发布35次查看
规定上传文件只能是图片 如果是其它文件则不能上传 这个怎么样限制呢?
if($_server['request_method']=='post'){ if(is_uploaded_file($_files['up']['tmp_name'])){ $path='./upload/'; is_dir($path) || mkdir($path,0777,true); $type=ltrim(strchr($_files['up']['type'],'/'),'/'); $filename = time().mt_rand(0, 9999).'.'.$type; $fullpath = $path . $filename; move_uploaded_file($_files['up']['tmp_name'], $fullpath); }}

回复内容: 规定上传文件只能是图片 如果是其它文件则不能上传 这个怎么样限制呢?
if($_server['request_method']=='post'){ if(is_uploaded_file($_files['up']['tmp_name'])){ $path='./upload/'; is_dir($path) || mkdir($path,0777,true); $type=ltrim(strchr($_files['up']['type'],'/'),'/'); $filename = time().mt_rand(0, 9999).'.'.$type; $fullpath = $path . $filename; move_uploaded_file($_files['up']['tmp_name'], $fullpath); }}

通过扩展名判断,有风险
通过mime types判断
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product