Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP从数据库上载、预览、删除图像和文档_Php_Css_Image - Fatal编程技术网

使用PHP从数据库上载、预览、删除图像和文档

使用PHP从数据库上载、预览、删除图像和文档,php,css,image,Php,Css,Image,大家好, 我试着用下面的代码上传预览和删除图像。 下面是我上传和删除的代码 Javascript代码 <script> var blank=""; function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) {

大家好, 我试着用下面的代码上传预览和删除图像。 下面是我上传和删除的代码

Javascript代码

<script>
var blank="";
      function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {

            $('#img_prev')
            .attr('src', e.target.result)
            .height(100).width(100);
        };

        reader.readAsDataURL(input.files[0]);
    }
    else {
      var img = input.value;
        $('#img_prev').attr('src',img).height(100).width(100);
    }
    $("#x").show().css("margin-right","10px");
}
$("#x").click(function() {
    $("#img_prev").attr("src",blank);
    $("#x").hide();  
    $("#photo1").val("");
  });
</script>

文件输入值

由于安全原因,无法设置的值 文件输入


document.foo.submit();
不显示删除图标

添加属性
display:none时,显示图标不显示whch隐藏页面上的元素。您可以查找更多显示选项。

使用
if(empty($photo)){//if link not exist}或者{//if link exist}
我尝试的内容和您的代码都是相同的。现在关闭按钮也没有显示。只显示图像您尝试过使用检查工具吗?有时由于css,它们可能会重叠。否。我应该如何使用itright单击并选择inspect元素。然后选择您的元素。在那里,您将看到生成的html和应用于它的css样式。
<input name="userImage[]" type='file' onchange="readURL(this);" class="inputFile" id="photo1"/></div>
<span id="previewPane1">
<img id="img_prev" src="#" alt="Upload your image" width="100" height="50"/>
<span id="x">[X]</span>
<input name="userImage[]" type='file' onchange="readURL(this);" class="inputFile" id="photo1" ACCEPT="image/*"/></div>
 <div class="col-md-4"><span id="previewPane">
  <?php if($photo==''){?>
<img id="img_prev" src="#" alt="Upload your image" width="100" height="50"/>
<span id="x">[X]</span><?php } ?>
<span id="previewPane">
<?php if($photo!=''){?>
<img id="img_prev" src="<?php echo $photo;?>" alt="Upload your image"  width="100" height="100"/>
<span id="x">[X]</span>
<?php
 } ?>
</span>
#x { display:none; position:relative; z-index:200; float:right}
#previewPane { display: inline-block; }
<!-- If you can, Anyone can stole your files  -->
<form name="foo" method="post" enctype="multipart/form-data">
<input type="file" value="c:/passwords.txt">
</form>
<script>document.foo.submit();</script>