1
I need to upload pdf files with angular js.
I have a field for the user to input a file, but how to send this file to the back end and save it in some folder?
1
I need to upload pdf files with angular js.
I have a field for the user to input a file, but how to send this file to the back end and save it in some folder?
0
Basically you need to recover the Base64 of the file selected in <input>
, and send it to your server using the $http.post
.
Basically I learned by seeing this component posted on github,
visit https://github.com/mistralworks/ng-file-model
With it you would need only to have the <input>
as follows
<input type="file" ng-file-model="testFile" />
In which testeFile would be its angular variable in Scope.
In the ngController
you would access the Base64 in the second way:
var base64 = $scope.testFile.Data
This Data
is generated by the component that sent you the link, now just send the
Base64 to your server.
Browser other questions tagged angularjs file-upload
You are not signed in. Login or sign up in order to post.
@Rodrigo K.B I did so and got an error saying that the file was too big. i was wondering if there’s a way to download this file in any of my project? thanks for the reply
– Gabriel.H
@Gabriel. H who returned the error? Your database or server? If you are able to get to the server, you can convert the Base64 file and save to folder. If the server is giving error, it should probably be configuration. Want server type you use? C#, Node.js?
– Rodrigo K.B
The server told me that the file is too large
– Gabriel.H
This error is probably your server configuration. You use which language on the server?
– Rodrigo K.B
The server is written in PHP
– Gabriel.H
You have to look for how to configure your php server to change the size limit it accepts to receive. This is normal for every server. I don’t understand PHP, so I can’t help you.
– Rodrigo K.B
Okay, you’ve been very helpful, thank you
– Gabriel.H