标签:
1 /** 2 *上传图片 3 */ 4 function showUpload_img($_FILES){ 5 6 $url_img=realpath(dirname(__FILE__).‘/../../‘.‘/wx_chat/img/‘).‘/‘; 7 8 if ($_FILES["img_name"]["type"] == "image/gif"||$_FILES["img_name"]["type"] == "image/png"||$_FILES["img_name"]["type"] == "image/jpeg") 9 { 10 if ($_FILES["img_name"]["error"] > 0) 11 { 12 13 return array( 14 ‘name‘=>‘‘, 15 ‘status‘=>0, 16 ‘info‘=>‘上传图片失败!‘.$_FILES["img_name"]["error"] 17 ); 18 } 19 else 20 { 21 if (file_exists($url_img . $_FILES["img_name"]["name"])) 22 { 23 return array( 24 ‘name‘=>$_FILES["img_name"]["name"], 25 ‘status‘=>0, 26 ‘info‘=>$_FILES["img_name"]["name"].‘已经存在,上传失败!‘ 27 ); 28 } 29 else 30 { 31 move_uploaded_file($_FILES["img_name"]["tmp_name"], 32 $url_img . $_FILES["img_name"]["name"]); 33 return array( 34 ‘name‘=>$_FILES["img_name"]["name"], 35 ‘status‘=>1, 36 ‘info‘=>‘上传成功!‘ 37 38 ); 39 } 40 } 41 }else 42 { 43 return array( 44 ‘name‘=>"", 45 ‘status‘=>0, 46 ‘info‘=>‘图片格式不对!‘ 47 ); 48 } 49 }
标签:
原文地址:http://www.cnblogs.com/hgj123/p/4564108.html