为了账号安全,请及时绑定邮箱和手机立即绑定

php添加记录到数据库为什么总是提示我文件类型错误?

php添加记录到数据库为什么总是提示我文件类型错误?

PHP
奥特曼还是变形金刚 2017-10-24 01:14:31
 <?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 回答

  • 1 回答
  • 0 关注
  • 721 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信