文件上传
来源:互联网 发布:springboot初始化数据 编辑:程序博客网 时间:2024/06/05 17:55
这是个简单的上传,没有判断大小,php默认限制文件大小为2M,主要函数$_files[],move_uploaded_file().
<?php
if($_POST[sub]){
if(is_uploaded_file($_FILES[file][tmp_name])){//判断是否取到临时文件,并保存php内部。返回值为1为真。
$file=$_FILES[file];
print_r($file); //不懂就打印下文件数组保存了哪些值和结构。
$name=$file[name];
$tmp=$file[tmp_name];
$size=$file[size];
$error=$file[error];
$type=$file[type];
}
switch($type){
case 'image/pjpeg' : $ok=1;
break;
case 'image/jpeg' : $ok=1;
break;
case 'image/gif' : $ok=1;
break;
case 'image/png' : $ok=1;
break;
}
if($error=='0'&& $ok==1){
move_uploaded_file($tmp,'upfile/'.$name);
echo "上传成功 ";
}else{
echo "上传失败";
}
}
?>
<form name="form" method="post" enctype="multipart/form-data" action="">
<input name="file" type="file" />
<input name="sub" type="submit" value="上传" />
</form>
- 文件上传---文件上传
- 上传文件
- 文件上传
- 上传文件
- 文件上传
- 文件上传
- 上传文件
- 上传文件
- 文件上传
- 文件上传
- 文件上传
- 文件上传
- 文件上传
- 文件上传
- 文件上传
- 上传文件
- 文件上传
- 文件上传
- html标签参考手册
- 对话框中加入标签页的5种方法
- malloc原理
- 【转】C语言实现stack模板
- oracle 字符串连接
- 文件上传
- 设置Eclipse里的默认编码
- 查看系统配置
- 《Java Servlet Programming》读书笔记_2010.06.10
- 完美卸載ORACLE
- 网上收集的C++笔试题目(7)
- 什么是作用域解析操作符?What is a scope resolution operator?
- 网上收集的C++笔试题目(8)
- Cygwin安装笔记