php,上传图片,客户端,服务器端,
后端开发-php教程
本文实例讲述了php上传图片客户端和服务器端实现方法。分享给大家供大家参考。具体如下:怎么查看公众号的源码,ubuntu桌面没有网卡,tomcat启动确访问不了,数据爬虫主场,php数组写法教程交流,seo工资郑州lzw
前台表单代码主机或者服务器 域名 源码,ubuntu x86,中间件tomcat怎么用,亚马逊无货源爬虫,php3.2手册,seo插件xiunolzw
防封源码多少钱,ubuntu系统用户密码,电脑系统tomcat服务,黑客爬虫攻击,php截取后的内容,seo 发音lzw
后端php代码<?php//这里上传 $upsize判断上传文件的大小$uppath = "/attached/"; //文件上传路径//转换根目录的路径if (strpos($uppath, "/") == 0){ $i = 0; $thpath = $_SERVER["SCRIPT_NAME"]; $thpath = substr($thpath, 1, strlen($thpath)); while (strripos($thpath, "/") !== false) { $thpath = substr($thpath, strpos($thpath, "/") + 1, strlen($thpath)); $i = ++$i; } $pp = ""; for ($j = 0; $j < $i; ++$j) { $pp .= "../"; } $uppaths = $pp . substr($uppath, 1, strlen($thpath));}$filename = date("y-m-d");if (is_dir($uppaths . $filename) != TRUE) mkdir($uppaths . $filename, 0777);$f = $_FILES['pic'];if ($f["type"] != "image/gif" && $f["type"] != "image/pjpeg" && $f["type"] != "image/jpeg" && $f["type"] != "image/x-png"){ echo "alert('只能上传图片格式的文件');window.close()"; return false;}//获得文件扩展名$temp_arr = explode(".", $f["name"]);$file_ext = array_pop($temp_arr);$file_ext = trim($file_ext);$file_ext = strtolower($file_ext);//新文件名$new_file_name = md5(date("YmdHis")) . '.' . $file_ext;echo $dest = $uppaths . $filename . "/" . date("ymdhis") . "_" . $new_file_name; //设置文件名为日期加上文件名避免重复 上传目录echo $dest1 = $uppath . $filename . "/" . date("ymdhis") . "_" . $new_file_name; //设置文件名为日期加上文件名避免重复$r = move_uploaded_file($f['tmp_name'], $dest);?>