php 简洁上传
2016-03-07 14:30
609 查看
if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ $upfile=$_FILES["upfile"]; $name=$upfile["name"];//上传文件的文件名 $type=$upfile["type"];//上传文件的类型 $size=$upfile["size"];//上传文件的大小 $tmp_name=$upfile["tmp_name"];//上传文件的临时存放路径 switch ($type){ case 'image/pjpeg':$okType=true; break; case 'image/jpeg':$okType=true; break; case 'image/gif':$okType=true; break; case 'image/png':$okType=true; break; } if($okType){ $wap_upaddress='/uploadfile/images/wap_'.time(); $error=$upfile["error"];//上传后系统返回的值 move_uploaded_file($tmp_name,$wap_upaddress); // $destination="/images/".$name; if($error>0){ echo "<script> alert('上传失败请重新上传');<script>"; } $_POST['pic']=$wap_upaddress; }else{ echo "<script> alert('请上传jpg,gif,png等格式的图片!');<script>"; } }
相关文章推荐
- php 的定界符 <<<eof 的问题
- 【PHP】PHP 7.0.4 发布
- ContentProvider的生命周期
- PHP - 继承 - 子类使用父类方法
- Matplotlib Tutorial(译)
- 搜索实现最近联系人 thinkPHP框架
- Zend Framework教程之MVC框架的Controller用法分析
- Zend Framework教程之路由功能Zend_Controller_Router详解
- 关于PHP的框架
- php session
- php中mkdir()函数的权限问题
- 使用getParts()上传多个文件
- PHP中file_exists与is_file,is_dir的区别介绍
- Zend Framework教程之Zend_Controller_Plugin插件用法详解
- php 学习笔记 -- 日期(四)
- getAttribute()与getParameter的区别
- ubuntu 12.04安装php的权限配制
- Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解
- phpStorm mac下的快捷键
- 黑马程序猿 IO流 ByteArrayInputStream与ByteArrayOutputStream