search
Homephp教程php手册php 文件上传系统手记

php 文件上传系统手记

Jun 13, 2016 pm 12:21 PM
phpuploadNotesdocumentregularuseofcodesystem

整个系统只有带码全部用PHP,没有JS,没有正则...纯纯的PHP...其实别的我也不会呵呵...
下面是原表单的html带码...
上传文件表单

复制代码 代码如下:




Map Name:




File Path:









表单中enctype="multipart/form-data"的意思,是设置表单的MIME编码。默认情况,这个编码格式是 application/x-www-form-urlencoded,不能用于文件上传;只有使用了multipart/form-data,才能完整的传递文件数据,进行下面的操作.enctype="multipart/form-data"是上传二进制数据; form里面的值以2进制流的方式传过去。
这句好像是没有用的...我原以为这个可以限制上传文件大小呢,上传文件大小只有在php.ini里或后面上传的文件的脚本里设置了...我程序里是直接设置php.ini中upload_max_filesize=6M的.
下面是上传程序
Code

复制代码 代码如下:


$uploaddir="./map/";
$typearr=array("rar","zip","w3m","w3x");
$findstr=array("/","\\"," ",""); //对名称进行过滤
$mapname=str_replace($findstr,'',($_POST['mapname']));
//取扩展名
function upfiletype($filename){
$arr=explode('.',$filename);
$a=count($arr)-1;
return $arr[$a];
}
//字符串是不是纯数字
function isNo($str){
$intarr=array('1','2','3','4','5','6','7','8','9','0','.');
$a=str_replace($intarr,'',$str);
return ($a=="")?1:0;
}
//////控制窗口大小///////
function html(){
echo

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools