?<?php?header('content-type:text/html;charset=utf-8');?include_once('conn.php');? ? if ($_POST['singername']) {? ? ? ? $SgName = $_POST['singername'];? ? ? ? $Sex = $_POST['sex'];? ? ? ? $SgCon = $_POST['content'];? ? ? ? $Cou = $_POST['cou'];? ? ? ? if($_FILES["file"]["error"])? ?{? ? echo $_FILES["file"]["error"];? ?}else? ? ? ?{ if(($_FILES["file"]["type"]=="image/jpg") && $_FILES["file"]["size"]<9999999)? ? ? ? ? ?{? ? ? ?$path='uploads';? ? ? ? //防止重名覆蓋? ? ? ? $uniName=md5(uniqid(microtime(true),true)).'.'.$ext;? ? ? ? //echo $uniName;exit;? ? ? ? $destination=$path.'/'.$uniName;? ? ? ? if(file_exists($destination))? ? ? ? {? ? ? ? ? ? echo "該文件已存在!";? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? //保存文件? ? ? ? ? ? move_uploaded_file($_FILES["file"]["tmp_name"],$destination);? ? ? ? ? ? $sql = "insert into singer(SgName,SgImg,Sex,SgCon,Cou) values('$SgName','$destination','$Sex','$SgCon','$Cou')";?? ? ? ? ? ? mysql_query($sql);? ? ? ? ? ? $num = mysql_affected_rows();? ? ? ? ? ?if ($num>0) {? ? ? ? ? ? ? echo "<script>alert('添加成功');location='gls.php';</script>";? ? ? ? ? ? }else{? ? ? ? ? ? ?echo "<script>alert('添加失敗');location='gls.php';</script>";}}? ? }? ? else? ? {? ? ? ? echo "文件類型不正確!";? ? }}}?>
- 1 回答
- 0 關(guān)注
- 770 瀏覽
添加回答
舉報
0/150
提交
取消