电脑安全

您当前的位置:主页 > 电脑安全 >

简单php 图片上传代码-网络编程

来源:[db:来源]标题:   上传    编辑:电脑技术全能网 时间:2019-09-18 18:01

原标题:简单php 图片上传代码-网络编程
   简略php 图片上传代码 php 上传图片代<?php$zpname=addslashes(isset($_POST['zpname'])?$_POST['zpname']:'');$zpurl=isset($_POST['zpurl'])?$_POST['zpurl']:'';$zpsay=addslashes(isset($_POST['zpsay'])?$_POST['zpsay']:'');$blueidea=isset($_POST['blueidea'])?$_POST['blueidea']:'';$up_path="../zp/";$up_size=100000;$up_name=md5(date("Y:m:d H:i:s"));$up_type=$_FILES['file']['type'];$up_exten="start:image/gifimage/pjpegimage/x-png";echo $up_type;echo(strrpos($up_exten,$up_type));//exit();//=$up_wh['mime'];$up_sava='';//echo($_FILES['file']['size']);//echo($_FILES['file']['type']);//exit();if($zpname=="" || $zpname>50){echo("<script>alert('作品称号不能为空或大于50个字符!');history.back();</script>");exit();}if(!ereg("^(http|https|ftp)/://((([a-zA-Z0-9/-]+/.){1,}[a-zA-Z]{2,4})|(localhost))(:[0-9]+){0,1}(/[a-zA-Z0-9/-/_/,/.//+&amp;%/$#/=~]+)*$",$zpurl)){echo("<script>alert('作品地点URL分歧法!');history.back();</script>");exit();}if($zpsay=="" || $zpsay>500){echo("<script>alert('作品简介不能为空或大于500个字符!');history.back();</script>");exit();}if(strrpos($up_exten,'image/x-png')){$up_sava=$up_path.$up_name.'.png';}if(strrpos($up_exten,'image/pjpeg')){$up_sava=$up_path.$up_name.'.jpg';}if(strrpos($up_exten,'image/gif')){$up_sava=$up_path.$up_name.'.gif';}if($up_sava==''){echo("<script>alert('对不起,你上传的范例错误,只同意上传 .gif .jpg .png');history.back();</script>");exit();}if($_FILES['file']['size']>$up_size){echo("<script>alert('上传文件不能大于100K');history.back();</script>");exit();}/*print_r($up_wh['mime']);exit();if($up_wh[0]>300 || $up_wh>400 || $up_wh[0]<93 || $up_wh<63){echo("<script>alert('图片宽度93-300之间,高度400-63之间');history.back();</script>");exit();}*/if(move_uploaded_file($_FILES['file']['tmp_name'],$up_sava)){up_insert($zpname,$zpurl,$zpsay,$blueidea,$up_name.'.gif');echo("<script>alert('上传胜利');location='".$_SERVER['HTTP_REFERER']."';</script>");}else{echo("<script>alert('未知过错');history.back();</script>");}function up_insert($zpname,$zpurl,$zpsay,$blueidea,$up_filename){$up_sava="zp/".$up_filename;connect();mysql_query($sql) or die('Insert into data fail:'.mysql_error());}?>

上一篇:Win2000安装Apache PHP4 MySQL-网络编程

下一篇:没有了