I am writing an application on ionicframework. Now I am developing functionality for user avatars. Now the application can get a picture from the gallery or camera and using the plugin http://www.newupdate.co/ngimgcrop-image-crop-directive-for-angularjs/ cut it to the avatar. The output is the string Base64. Now I need to upload it to the server or as is, i.e. in Base64, or write to a file and send the ready file to the server. When I try to send as is, I apparently exceed the limit on the length of the line and the server does not process my request.

Question number 1: how to send pictures to the server in Base64?

Or question number 2 for an alternative variant: how to save the Base64 line to a file?

  • You send the data as base64 for saving by which method? GET or POST? - Airat
  • In the API server provides POST. But you can rewrite. - DenniLa2

2 answers 2

It should be noted that if you get error 414 - the string is too long, you must send the data to the body post, not to the url post. You can send base64, receive and save as a file on the server, write a link to the server disk space in the database.

    Found an alternative solution: https://github.com/wymsee/cordova-imageResizer .