1

The problem does not happen on Android. Only IOS.

So I have a HTML form which takes capture from a camera or photo. Android files are fine but IOS are not.

Small to Medium files probably less than 200kb are fine on IOS. Anything large and it does not work, both image from gallery or camera. On the iOS you get the option to reduce the file size before uploading it and so the small images do work.

I get an error in JS which says "unterminated string literal" which means its corrupt or not completed.

This has been with all of the IOS devices (iPad and Iphones), latest versions of Safari as well.

What could be a way around this whilst still maintaining the same code. Are there some sort of base64 size limits on iOS.

async function saveimage()
{
    var imageexists = false;
    var base64result = document.getElementById("b64txt").value.split(',')[1];
    var filetype = document.getElementById("b64txt").value.split(',')[0];
    var filename = document.forms[1]['pic'].files[0].name;
  
    //check if file already exists
    for (i = 0; i < images.length; i++) {
        if (images[i].base64 == base64result && images[i].filetype == filetype && images[i].filename == filename) { imageexists=true}
    }

    if (imageexists == false) {
        var img = new image(base64result,filename , filetype);
        images.push(img);
        var json = JSON.stringify(images);
        document.getElementById("ContentPlaceHolder1_hd_images").value = json;
    }
  
    showthumbnails()
}

I have checked the size and charachter limits on the devices using a snippet that checks for memory allocation. All seems reasonable. Its well above what I need as the average photo will be 3-5MB.

Could it be that the HTML element has an issue with the length of a string since the code is storing data inside an element?

Usman
  • 136
  • 3
  • 17
  • 1
    You can try the snippet in https://stackoverflow.com/questions/34957890/javascript-string-size-limit-256-mb-for-me-is-it-the-same-for-all-browsers on your iOS device. – tevemadar Aug 08 '21 at 15:48
  • IOS device crashes when trying to use that in the JS script. Where the code calls binsearch function and passes test as the first argument, is that meant to be a variable or a call to the test() function? – Usman Aug 08 '21 at 16:45
  • When using that snippet of code. Since IOS was crashing, I reduced 52 to 24 and the script suddenly loads. I get an output result of 31 Megabytes. Seems like its probably more than I would need for a base 64 file. I am inserting this into an HTML element and then picking it up again. I need to check for this. Thanks for this snippet. – Usman Aug 08 '21 at 17:23

0 Answers0