모바일 장치 이미지 라이브러리에서 이미지를 업로드하는 데 angular-file-upload.min.js를 사용하는 모바일 장치 용 웹 사이트를 구축하고 있습니다.angularjs 업로드하기 전에 이미지 압축
html 코드 :
<div>
<div class="rating-camera-icon">
<input type="file" accept="image/*" name="file" ng-file-
select="onFileSelect($files)">
</div>
<img ng-show="fileName" ng-src="server/{{fileName}}" width="40"
style="margin-left:10px">
</div>
코드 :
$scope.onFileSelect = function($files) {
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
if (!file.type.match(/image.*/)) {
// this file is not an image.
};
$scope.upload = $upload.upload({
url: BASE_URL + 'upload.php',
data: {myObj: $scope.myModelObj},
file: file
}).progress(function(evt) {
// console.log('percent: ' + parseInt(100.0 * evt.loaded/evt.total));
// $scope.fileProgress = evt.loaded/evt.total * 100.0;
}).success(function(data, status, headers, config) {
// file is uploaded successfully
$scope.fileName = data;
});
}
};
업로드 모바일 장치에서 매우 느립니다. 파일을 압축하는 방법은 무엇입니까?
네이티브 응용 프로그램을 사용하지 않는 경우 당신은 또한 JPG와 같은 이미지의 대부분은 이미 내가 아는 한 압축 파일을 압축 할 수없는 것이없는 넌 할 수있어. –
업로드하기 전에 이미지 조작을 원할 경우 도움이 될 수 있습니다. http://stackoverflow.com/questions/2434458/image-resizing-client-side-with-javascript-before-upload-to-the-server –