以下为引用的内容: <? if($_FILES['sytp']['name']!="none"&&$_FILES['sytp']['name']!=""){//判断上传文件是否为空 $thistype=$_FILES['sytp']['type'];//将上传的类型传给$thistype //echo time().$_FILES['sytp']['name']; //exit; if("image/pjpeg"==$thistype or "application/x-shockwave-flash"==$thistype or "image/gif"==$thistype){//判断是否是我要的类型 $file_name = "shouyetupian/".time().$_FILES['sytp']['name'];//time()是为了区分两个文件不是同一时间传的 include("../connect.php");//调用connect.php里的内容 $sql="select count(*) from shangchuantu"; $result=mysql_query($sql,$db); $jie=mysql_fetch_row($result); $zhong=$jie[0]; if($zhong<5){ $sql1="select max(paixu) from shangchuantu"; $result1=mysql_query($sql1,$db); $jie1=mysql_fetch_row($result1); $zhong1=$jie1[0]; $zhong1=$zhong1+1; $query="insert into shangchuantu values('','$file_name','".$_POST['url']."','','$zhong1')"; mysql_query($query,$db);
if(!move_uploaded_file($_FILES['sytp']['tmp_name'], $file_name)) {//上传文件,$_FILES['sctb']['tmp_name']临时目录传到$file_name实际目录 ?> <script language="javascript"> alert("文件上传失败,请稍候再试"); window.history.back(); </script> <? }else{//上传成功 ?> <script language="javascript"> alert("文件上传成功!"); location.href="shanchuantu.php";
</script> <?
} }else{ ?> <script language="javascript"> alert("图片不能超过5张"); window.history.back(); </script> <? } }else{//如果类型不对 ?> <script language="javascript"> alert("文件上传失败,请稍候再试"); window.history.back(); </script> <?
} }else{ ?> <script language="javascript"> alert("请选择上传图片"); window.history.back(); </script> <? } ?>
|