简体   繁体   English

在使用ng-file-upload上传之前如何预览图像

[英]How to preview image before upload with ng-file-upload

This is code snippet. 这是代码片段。

When user select a file by clicking on Change Image button, file gets selected and name is displayed in text box. 当用户通过单击“更改图像”按钮选择文件时,文件被选中,名称显示在文本框中。

<img src="" alt="" border=3 height=75 width=75><br><br>

<input type="text" ng-model="b.files[0].name" data-ng-hide="!uploadMode" readonly="readonly">

<button ngf-select ng-model="b.files" class="btn btn-success btn-sm" ng-click="uploadMode=1">
    <span class="glyphicon glyphicon-picture"></span> Change Image
</button>

I also want to display the image of selected file to preview to user, before actual upload. 我还想在实际上传之前显示所选文件的图像以预览给用户。

Can please any one help me, what changes i need to do for that? 可以请任何人帮助我,为此我需要做哪些更改?

Take a look at the example ( ngThumb directive). 看一下示例ngThumb指令)。 Basically, it's all about using the FileReader API and listening to the appropriate events. 基本上,这都是关于使用FileReader API并监听适当的事件的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM