Search Posts

Category: file

How to edit File object in javascript

My drag-dropped file looks like the below: • [File(1351429)] 1. 0:File(1351429) 1. lastModified:1524514419721 2. lastModifiedDate:Mon Apr 23 2018 13:13:39 GMT-0700 (Pacific Daylight Time) {} 3. name:xxxxxx 4. size:xxxxxxx 5. type:xxxxx 6. webkitRelativePath:”” 7. proto:File 2. length:1 3. proto:Array(0) I want to modify the file type. How can I do it? Source: AngularJS

$_FILES empty when trying to upload file on server using AngularJS and PHP

All data if correctly sent to server in a different $http post request. Then, when I send the file in order to upload it, I can’t find how to make it work. I’ve tried to use FormData but I can’t get it to work either… HTML <input type=”file” class=”form-control-file col-sm-6″ ng-model=”request.addedFile” id=”added-file” files-input /> FilesInput Directive (function() { ‘use strict’; devRequestApp.directive(“filesInput”, function() { return { require: “ngModel”, link: function postLink(scope, elem, attrs, ngModel) { elem.on(“change”, […]

Empty file passed from AngularJS to Php

When AngularJS script sends an image file to Php the file seems empty. In PHP sizeof($_FILES) returns 0. Any ideas? Thanks! HTML code: <div ng-app=”myApp” ng-controller=”myCtrl”> <form name=”myForm”> <div> <input type=”file” ngf-select=”onFileSelect(file)” name=”file”> <span ng-show=”fileMsg”>{{fileMsg}}</span> </div> </form> </div> AngularJS code: var app = angular.module(‘myApp’, [‘ngFileUpload’]); app.controller(‘myCtrl’, function($scope, $http) { $scope.fileMsg = “Checkpoint 1”; $scope.onFileSelect = function(file) { var fd = new FormData(); fd.append(‘file’, file); $“save_img.php”, fd, { transformRequest: angular.identity, headers: {‘Content-Type’: undefined} }) .then(function(response){ $scope.fileMsg […]

AngularJS function not triggered via ngf-select

Trying to upload an image file and process it in an AngularJS function called onFileSelect. However after the Choose File button was clicked the value of $scope.fileMsg inside onFileSelect was not updated. Any tips? Thanks a bunch! <div ng-app=”myApp” ng-controller=”myCtrl”> <form name=”myForm”> <div> <input type=”file” ngf-select=”onFileSelect(file)” name=”file”> <span ng-show=”fileMsg”>{{fileMsg}}</span> </div> </form> </div> <script> var app = angular.module(‘myApp’, []); app.controller(‘myCtrl’, function($scope, $http) { $scope.fileMsg = “Checkpoint 1”; $scope.onFileSelect = function(file) { $scope.fileMsg = “Checkpoint 2”; } […]

ng-disabled in Angular is not working immediately

I am editing the file, here i can change the filename as well as i can add another file for versions, If I have chosen the file, filename edit field should be disabled immediately. I have tried this following code, but its not get disabled until i type something in filename field. My View code: <div class=”ipfield”> <label class=”plclabel”>Choose file</label> <input type=”file” class=”txt_box” id=”newfile” onchange=”angular.element(this).scope().fileNameChanged()”> </div <div class=”ipfield” > <label class=”plclabel”>File Name</label> <input type=”text” class=”txt_box” […]

How to use fileReader in angular js [duplicate]

This question already has an answer here: File Upload using AngularJS 26 answers ng-model for <input type=“file”/> 11 answers I have a function only for up function uploadBlogIamge(blogUrl, data, successMsg, errorMsg) { delete data.images; var file = document.querySelector(‘input[type=file]’).files[0]; var reader = new FileReader(); if (file) { data.imageName = reader.readAsDataURL(file); } Upload.upload({ url: $rootScope.server_url + blogUrl, //webAPI exposed to upload the file arrayKey: ”, data: data //pass file as data, should be user ng-model }).then(function (resp) […]

Memory Leak while using FileReader

I am using HTML FileReader and readAsDataURL but the memory consumption of my application keeps increasing as I upload new files. I have configured it to accept only one file. Whenever I select new file it doesn’t clear the memory used by old file. What could be the possible way to fix it? Source: AngularJS

How do I upload a file to an ng-repeated model?

I have an angular controller that is supposed to update person data. With text and date fields, that works just fine, I have <ul> <li ng-repeat=”person in $ctrl.persons | filter:$ctrl.query”> … <div ng-show=”person.edit”> <label>Full Name*:</label><input class=”edit-person” ng-model=”person.fullname” /><br /> <label>Birthdate:</label><input class=”edit-person” type=”date” ng-model=”person.birthdate” /><br /> <label>Deathdate:</label><input class=”edit-person” type=”date” ng-model=”person.deathdate” /><br /> <label>Description: </label><input class=”edit-person” type=”text” ng-model=”person.description” /><br /> <img ng-src=”{{person.picture}}” width=”100px” height=”100px” /><br /> <label>Picture: </label><input class=”edit-person” type=”file” accept=”image/*” ng-file-select=”handleEditPersonFiles(this.files);” /><br /> <button ng-click=”$ctrl.submitEdit(person); person.edit […]