Created
December 13, 2013 22:54
-
-
Save jreading/7952848 to your computer and use it in GitHub Desktop.
File uploading in angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" onchange="angular.element(this).scope().myController.uploadFile(this.files[0]); angular.element(this).scope().$digest();"> | |
var uploadFile = function(file) { | |
var formData = new FormData(); | |
formData.append('file', file); | |
$http({ | |
method: 'POST', | |
url: 'url-to-accept-file', | |
data: formData, | |
headers: { 'Content-Type': undefined }, | |
transformRequest: function(data) { return data; } | |
}) | |
.success(handleSuccess) | |
.error(showError); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment