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判断
