【问题标题】:php file upload to the database by update queryphp文件通过更新查询上传到数据库
【发布时间】:2016-01-29 02:48:57
【问题描述】:

我正在尝试使用 php 文件上传将上传图像更新到文件夹,但无法在数据库中获取先前出现的图像。这是我的代码,问题是我无法从数据库中获取文件上传部分中的前一张图片。请帮忙。

if(isset($_GET['msg']))
                    {
                            echo $_GET['msg'];
                    }
        $id=(isset($_GET['id']))?$_GET['id']:'';
        $val=view_data1_event($id);
        if (isset($_POST["events"])&&isset($_POST["description"])) 
            {
                $id=$_POST["id"]; 
                $title=$_POST["events"];
                $description=$_POST["description"];
                $filetmp=$_FILES["images"]["tmp_name"];
                $filename=$_FILES["images"]["name"];
                $filetype=$_FILES["images"]["type"];
                $filepath= "photo2/".$filename;
                move_uploaded_file( $filetmp,$filepath);
                $update1=update_query($title,$description,$filename,$filepath,$id);


                if($update1)
                    {
                        echo "<script>location.href='hotel1_galery_event.php'</script>";
                    }
            }

HTML

<form action="hotel2_galery_eventedit.php" method="post" class="col-sm-4" enctype="multipart/form-data">
 <div class="form-group has-info">
                  <label>Event Related images</label>
                  <input type="file" name="images">
                  <input type="hidden" name="image_name" value="<?php echo $val->image_name?>">
                  <input type="hidden" name="image_path" value="<?php echo $val->image_path?>">
                  </div>
                  <button type="submit" class="btn btn-primary">
                  <span>UPDATE</span>
                  </button> 
                            </form>

【问题讨论】:

    标签: javascript php html database image


    【解决方案1】:

    你的表单方法是post,你在php中使用get

    请将所有GET 替换为POST

    if(isset($_GET['msg']))
    

    应该是这样的,

    if(isset($_POST['msg']))
    

    【讨论】:

      猜你喜欢
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 2023-04-10
      • 1970-01-01
      • 2016-11-07
      相关资源
      最近更新 更多