मैं सर्वर पर फ़ाइल अपलोड करने के लिए Angular-File-Upload का उपयोग कर रहा हूं। सबकुछ ठीक काम करता है और फाइल डीबी में सहेजी जा सकती है।कोणीय फ़ाइल अपलोड
सवाल यह है कि, मैं संपादन मोड में सहेजी गई छवियों को वापस कैसे लोड कर सकता हूं?
यह canvas
बनाने के लिए निर्देश जब अपलोड पिक
'use strict';
myApp
.directive('ngThumb', ['$window', function($window) {
var helper = {
support: !!($window.FileReader && $window.CanvasRenderingContext2D),
isFile: function(item) {
return angular.isObject(item) && item instanceof $window.File;
},
isImage: function(file) {
var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
}
};
return {
restrict: 'A',
template: '<canvas/>',
link: function(scope, element, attributes) {
if (!helper.support) return;
var params = scope.$eval(attributes.ngThumb);
if (!helper.isFile(params.file)) return;
if (!helper.isImage(params.file)) return;
var canvas = element.find('canvas');
var reader = new FileReader();
reader.onload = onLoadFile;
reader.readAsDataURL(params.file);
function onLoadFile(event) {
var img = new Image();
img.onload = onLoadImage;
img.src = event.target.result;
}
function onLoadImage() {
var width = params.width || this.width/this.height * params.height;
var height = params.height || this.height/this.width * params.width;
canvas.attr({ width: width, height: height });
canvas[0].getContext('2d').drawImage(this, 0, 0, width, height);
}
}
};
}]);
है यह एक HTML स्निपेट कि लोड कैनवास जब वहाँ एक अपलोड है:
<div class="table-responsive" ng-hide="!uploaderImages.queue.length">
<table class="table">
<thead>
<tr>
<th width="50%">Name</th>
<th ng-show="uploaderImages.isHTML5">Size</th>
<th ng-show="uploaderImages.isHTML5">Progress</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in uploaderImages.queue">
<td><strong>{{ item.file.name }}</strong>
<div ng-show="uploaderImages.isHTML5" ng-thumb="{ file: item._file, height: 100 }"></div>
</td>
<td ng-show="uploaderImages.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
<td ng-show="uploaderImages.isHTML5">
<div class="progress progress-xs margin-bottom-0">
<div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
</div></td>
<td class="text-center">
<span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
<span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
<span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
</td>
<td nowrap>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button></td>
</tr>
</tbody>
</table>
</div>
धन्यवाद !!
क्या आप अपनी समस्या को और विस्तार से समझा सकते हैं? "छवियों को वापस लोड करें" और "संपादन मोड" का क्या अर्थ है? –
जब आप 'लोड बैक' कहते हैं, तो क्या आपका मतलब है कि उन्हें डेटाबेस से कैसे पुनर्प्राप्त करें और उन्हें कैनवास में लोड करने के लिए उपलब्ध कराएं?आप डेटाबेस से छवियों को कैसे पुनर्प्राप्त कर रहे हैं? – br3w5
यदि कोई जवाब सही था तो दिलचस्प होगा? –