danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

How to append already uploaded images into model #1976

Closed appsierra-developer closed 7 years ago

appsierra-developer commented 7 years ago

First, Thank you for making this wonderful plugin. Made my life so much easier. :+1: Coming to the point, I have some already uploaded images on my server. Hence they are being returned in JSON as full file url(or path) in this format http://server.com/uploads/file.jpg

What I am confused in is how to append those into model so it can be shown in where I am appending new images. My html (pseudo code):

<div ng-repeat="file in files">
<img src="file" alt="file.name">
<span>{{ file.name }}</span>
</div>

This works when I pick file. But how do I append already uploaded files into this? Please help

appsierra-developer commented 7 years ago

Duh, just found out

Upload.urlToBlob(URL).then(function(blob){
$scope.files.push(blob);
});

Thanks again for wonderful plugin