php如何实现上传指定类型及指定大小的文件
下面的代码演示了php中如何获取用户上传的文件,并限制文件类型的一般图片文件,最后保存到服务器 HTML源码: php上传并判断文件类型源码 $aErrors = ""; if ( !empty( $thefile_name ) ) // no file selected { $$thefile_type=$_FILES["file"]["type"]; if ( ( $thefile_type == "image/gif" ) || ( $thefile_type == "image/pjpeg" ) || ( $thefile_type == "image/jpeg" ) ){ if ( $thefile_size < ( 1024 * 100 ) ){ $aCurBasePath = dirname( $PATH_TRANSLATED ); $aNewName = $aCurBasePath . $thefile_name; copy( $thefile,$aNewName ); } else { $aErrors .= "超过最大上传文件限制"; } } else { $aErrors .= "文件不是图片"; } } else{ $aErrors .= "没有选中任何文件上传"; } ?> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |