0

I am working on mobile app development. I am uploading image in base64 string format. i want image name and image size from base64 image string.

$("body").append("<img id='hiddenImage' src='" + "data:image/jpeg;base64," + imageData + "' />");
var file_size = $('#hiddenImage').size();
alert(file_size);
var width = $('#hiddenImage').width();
var height = $('#hiddenImage').height();
$('#hiddenImage').remove();
alert("width:" + width + " height:" + height);
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
  • You need to get the dimensions after successful load. You cannot get a name. Also why append when you remove it anyway? Just keep it in memory – mplungjan Sep 01 '15 at 09:00
  • Hey Madhavi You can calculate the file size from base64 string. http://stackoverflow.com/questions/11761889/get-image-file-size-from-base64-string However, I have never heard of getting filename from the same. In case you're using to select file, then its easy to get all the details using HTML5 FileReader. – ShivangiBilora Sep 01 '15 at 09:04
  • Here is how to get the dimensions: http://jsfiddle.net/mplungjan/jnu8eu2w/ – mplungjan Sep 01 '15 at 09:09

0 Answers0