The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

File Uploads

File Uploads

7:42
The `file` input type is missing from the ng-model directive, so you need to "roll your own" solution for file uploads with AngularJS.
Watch this lesson now
Avatar
egghead.io

The file input type is missing from the ng-model directive, so you need to "roll your own" solution for file uploads with AngularJS.

Avatar
Joel

In the video Joe uses a .NET service for handling that portion of the file upload. The lesson download includes a small Node Express server that does the same thing. See the README.

In reply to egghead.io
Avatar
Chris

i am getting an error saying the .assign function is not defined. Here is the code i am using:

.directive('cspecFileInput', ['$parse', function($parse){
return {
restrict: 'A',
link: function(scope,elm,attrs){
elm.bind('change', function() {
$parse(attrs.cspecfileInput)
.assign(scope,elm[0].files);
scope.$apply();
});
}
};
}])

Any idea why I would get that?

In reply to egghead.io
Avatar
Joseph

$parse(attrs.cspecfileInput)
should be
$parse(attrs.cspecFileInput)

In reply to Chris
Avatar
Chris

Ok. i feel silly now.. I looked at that 100 times and didn't see that. Thank you

In reply to Joseph
Avatar
Jose

Hi,
I have seen the video tutorial and works fine, but furthermore i would like to save the images on the server (not only the name or path). How can i do this?

Avatar
Christopher

When accessing the files that were returned in both the function filesChanged and the directive fileInput, I noticed that I had to use

elm.files[0]

Does this represent a recent change? Thanks in advance!

Avatar
Ashley Connor

angular-file-upload was renamed to ng-file-upload. Don't use nervgh/angular-file-upload it's buggy as hell.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?