<?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 "文件类型不正确!";
}
}
}
?>