【问题标题】:how to get the name tag of an image如何获取图像的名称标签
【发布时间】:2017-03-29 09:22:51
【问题描述】:

我有一个来自我的数据库的图像在另一个表中显示为$draft['draft_image'],我想将此数据发送到另一个表,但我遇到了问题,因为此代码似乎不起作用..当我尝试单击已发布按钮没有正在发送的数据。我使用var_dump 显示插入的数据,但检查元素中没有显示任何内容。知道如何获取图像吗?这就是我的 draft_image 里面的内容.. ../images/article/md.png

<form method="POST" enctype="multipart/form-data">
   <img data-name="title_image" src="./<?= $draft['draft_image'];?>" style="margin-top:5px;" width="70%" height="55%"><br><br>
<?php
  }
?>
<button type="submit" name="submit" class="btn3 btn-default">Publish</button>
</form>

if (isset($_POST['submit'])) {
        $id = $session_id;  
        $file = $_POST['title_image'];

        $ress = $db->draftpublished($id,$file);
        echo $ress;
          }
      ?>

【问题讨论】:

  • 不是表单元素,这就是你不能用 POST 请求发送它的方式
  • 知道如何获取$draft['draft_image']的数据并发布吗?
  • 你可以使用input type hidden 并传递post值
  • 你想得到什么? $draft['draft_image']的值?

标签: php html image post tags


【解决方案1】:

您可以使用隐藏类型 ex 传递值:

<form method="POST" enctype="multipart/form-data">
       <img data-name="title_image" src="./<?= $draft['draft_image'];?>" style="margin-top:5px;" width="70%" height="55%"><br><br>
       <input type="hidden" name="imgsrc" value="<?= $draft['draft_image'];?>">
<?php
  }
?>
<button type="submit" name="submit" class="btn3 btn-default">Publish</button>
</form>

if (isset($_POST['submit'])) {
        $id = $session_id;  
        $file = $_POST['imgsrc'];

        $ress = $db->draftpublished($id,$file);
        echo $ress;
          }
      ?>

【讨论】:

    【解决方案2】:
    <form method="POST" enctype="multipart/form-data">
     <!-- added ----------------- -->
     <input type="hidden" name="title_image" value="<?=$draft['draft_image']?>">
    
       <img data-name="title_image" src="./<?= $draft['draft_image'];?>" style="margin-top:5px;" width="70%" height="55%"><br><br>
    <?php
      }
    ?>
    <button type="submit" name="submit" class="btn3 btn-default">Publish</button>
    </form>
    
    if (isset($_POST['submit'])) {
        $id = $session_id;  
        $file = $_POST['title_image'];
    
        $ress = $db->draftpublished($id,$file);
        echo $ress;
          }
      ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-14
      • 2014-07-12
      • 1970-01-01
      • 2020-05-31
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 2019-11-29
      相关资源
      最近更新 更多