douwen2072 2017-01-31 19:51
浏览 26

php图片上传无效

I have asked this question before I made changes to my code and my image upload is not working at all I have checked username password, and Root they are all correct. my code will not show any errors I dont know what to do anymore can someone please help me? I have changed my connection for security reasons

<?php 

$con = mysqli_connect("localhost", "torcdesi_jone45", "password", "torcdesi_amazing");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$query_image = 'INSERT INTO shirt_table (images3) 
                values( "' . $_FILES['file3']['name'] . '")';
?>
<?php

include("configur.php");
if($_POST) { 
    // $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.

     if ($_FILES["file3"]["error"] > 0) {
        // if there is error in file uploading 
        echo "Return Code: " . $_FILES["file3"]["error"] . "<br />";
    } else {
        // check if file already exit in "images" folder.
        if (file_exists("shirtimgs/" . $_FILES["file3"]["name"])) {
        } else { 
            //move_uploaded_file function will upload your image. 
            if(move_uploaded_file($_FILES["file3"]["tmp_name"],"shirtimgs/" . $_FILES["file3"]["name"]))
            {
                // If file has uploaded successfully, store its name in data base
                $query_image = "insert into shirt_table";

                if(mysqli_query($link, $query_image)) {
                    echo "Stored in: " . "shirtimgs/" . $_FILES["file3"]["name"];
                } else {   
                    echo'';
                }
            }
        }
    }
 }
 ?>
  • 写回答

1条回答 默认 最新

  • doulu8415 2017-01-31 20:11
    关注

    As I stated in comments, your form is missing a proper enctype to handle files.

    This I know, since I saw your other question that did not contain it in the form.

    <form enctype="multipart/form-data" action="__URL__" method="POST">
    

    As per the manual:

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示