Upload a PDF file

Asked

Viewed 679 times

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 answer

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.

  • @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 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?

  • The server told me that the file is too large

  • This error is probably your server configuration. You use which language on the server?

  • The server is written in PHP

  • 1

    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.

  • Okay, you’ve been very helpful, thank you

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.