? <?php?header('content-type:text/html;charset=utf-8');?require_once('conn.php');? ? $fileInfo=$_FILES['myFile'];? ? $filename=$fileInfo['name'];? ? $type=$fileInfo['type'];? ? $tmp_name=$fileInfo['tmp_name'];? ? $size=$fileInfo['size'];? ? $error=$fileInfo['error'];? ? $maxSize=99999999;? ? $allowExt=array('jpg','jpeg','mp3');? ? if ($error==UPLOAD_ERR_OK) {? ? ? ? if ($fileInfo['size']>$maxSize) {? ? ? ? ? ? exit('文件過大');? ? ? ? }? ? ? ? $ext=pathinfo($fileInfo['name'],PATHINFO_EXTENSION);? ? ? ? if(!in_array($ext, $allowExt)){? ? ? ? ? ? exit('非法文件類型');? ? ? ? }? ? ? ? if (!is_uploaded_file($fileInfo['tmp_name'])) {? ? ? ? ? ? exit('文件不是通過HTTP POST方式上傳來的');?? ? ? ? }? ? ? ? $path='uploads';? ? ? ? //防止重名覆蓋? ? ? ? $uniName=md5(uniqid(microtime(true),true)).'.'.$ext;? ? ? ? //echo $uniName;exit;? ? ? ? $destination=$path.'/'.$uniName;? ? ? ? //$destination=$path.'/'.date("YmdHis").$fileInfo['name'];? ? ? ? if (move_uploaded_file($fileInfo['tmp_name'],$destination)) {? ? ? ? ? ? echo '文件上傳成功';? ? ? ? }else{? ? ? ? ? ? echo '文件上傳失敗 ?';? ? ? ? }? ??? ? }?>?<?php?require_once('conn.php');?if (!empty($_POST['submit'])){? ? $SgName=$_POST["singername"];? ? $Sex=$_POST["sex"];? ? $SgCon=$_POST["content"];? ? $Cou=$_POST["cou"];? ??? ? $sql="select 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>";}?}??>
- 3 回答
- 0 關(guān)注
- 979 瀏覽
添加回答
舉報(bào)
0/150
提交
取消