php file upload problem

后端 未结 6 1245
野性不改
野性不改 2021-01-23 19:39

This code works properly in my localhost. I am using xampp 1.7.3. but when I put it in the live server it shows Possible file upload attack!. \'upload/\' is the fol

6条回答
  •  别那么骄傲
    2021-01-23 20:32

    Try this code

     $fltype=$_FILES['userfile']['type']; 
        echo $fltype."
    "; /*if($_FILES['userfile']['type'] != "image/gif") { echo "Sorry, we only allow uploading GIF images"; exit; }*/ $uploaddir = 'uploads/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $imgname=basename($_FILES['userfile']['name']); $desc=$_POST["desc"]; echo "
    ".$imgname."
    "; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "File uploading failed.\n"; } $con=mysql_connect("localhost","root",""); $select=mysql_select_db("n1",$con); $sql="insert into tblimage (imagename,description) values('$imgname','$desc')"; echo "
    ".$sql; $rs=mysql_query($sql); if($rs) { echo "
    Record inserted in table.
    "; } else { echo "
    Error in table insersion.
    "; } echo "

    uploaded image is::::

    "; echo ""; ?>

提交回复
热议问题