ds3422222 2016-06-25 00:13
浏览 18
已采纳

按钮编辑图像

I want to make a gallery for my website. I developed the code to add an image, but I want to add an edit button to images, like Facebook.

I want it so when you pass the mouse on the image, you can the see an edit button.

I've searched a lot but without anything helpful.

Here's my code:

<?php
  if(isset($_POST['upload_img'])){

    $file_name = $_FILES['images']['name'];
    $file_type = $_FILES['images']['type'];
    $file_size = $_FILES['images']['size'];
    $file_tmp = $_FILES['images']['tmp_name'];
    if($file_name){
      move_uploaded_file($file_tmp,"img/$file_name");
    }
  }

?>
<html>
<head>
  <title>Test upload img</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<label>Upload Image</label><br>
<input type="file" name="images"><br><br>
<input type="submit" value="upload img" name="upload_img">
</form>

<?php
$folder="img/";
if(is_dir($folder)){
if($handle = opendir($folder)){
while(($file=readdir($handle))!=false){
if($file==='.' || $file==='..')
continue;
echo'<img src="img/'.$file.'"width="150" height="150">
<form>
<input type="file" value="Edit">
</form>
 ';
}
closedir($handle);
}
}
?>

</body>
</html>

</div>
  • 写回答

1条回答 默认 最新

  • dthhlf1777 2016-06-25 00:25
    关注

    hope this help.

    HTML:

    <div class="image_container">
      <input type="file" class="edit_btn" value="Edit">
      <img src="img.jpg">
    </div>
    

    CSS:

    .image_container{ position: relative; }
    .edit_btn{ postion: asolute; top: 10px; right: 10px; background-color: #000; color: #fff; padding: 8px 15px; border: 0; display: none; }
    .image_container:hover .edit_btn{ display: block; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作