sending formdata file fails


The application works on android device version 5.0, but fails in 4.2. The problem is sending blob data appended in formdata. The code is as follows:

problemData = new FormData();
problemData.append('problem', $scope.problem['id']);
problemData.append('description', $scope.imgcomment);
var blobdata = dataURItoBlob("data:image/jpeg;base64,"+$scope.lastImage);

problemData.append('image', blobdata, 'problem.jpg');

$, problemData, {transformRequest: angular.identity, headers: {'Content-Type': undefined}})
.success( function (data){
   $scope.lastImage = false;
.error(function(e, s, h) {
    $scope.lastImage = false;

as I’ve written above this code works with android 5.0 but fails with 4.2.
The dataURItoBlob function transforms uridata to blob and I’ve checked it’s working properly on both devices.

The data is sent to an api-server and always receives 400 error code. I have redirected the post url to a php script and this is the image data received:

array (
  'image' => 
  array (
    'name' => 'Blob97524901ba8f43d2b0677909c93a5dce',
    'type' => 'image/jpeg',
    'tmp_name' => '/tmp/phpf11B1i',
    'error' => 0,
    'size' => 0,

Size is 0 and the name is not problem.jpg as was specified in code.

Could be append function on FormData is working different? Or the problem must be in


Don’t you have to serialize data before sending it with http?


I works perfectly only with formdata on android 5.0 device, but something fails on 4.2.


Hi @xdiume,
Did you solve this problem ? I’m facing the same kind of issue, it’s just that in my case it is not working even on android 5.0 device