1
votes

I have a input type file placed in a UIWebview. When a user selects a file from the iPad/iPhone, I need to save the file to my remote server. I have tried to encrypt the file to base64 and then using jquery ajax, send it to the API that decodes the file and then saves it to the server folder. But when as I encrypt the file, and make the ajax call, my ajax success function returns 'Undefined' may be because the size of the data that I send(base64 string) is too large.

$.ajax({
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        url: 'https://www.myserver.com/api/Controller/Method',
        data: JSON.stringify({Filename: "base64 string" , Questionid: '28faf0fb-9d12-477c-ada5-2adc816063c7' , FileExt: "png" ,sid:'45bdd775-477d-4ca2-9d89-9724366aec36'}),
        processData: false,
        dataType: 'json',
        success: function(response) { alert(response); },
        error: function(xhr, ajaxOptions, thrownError) {alert(xhr.responseText); }
});
1
Not likely. Do a test with 10 bytes and see if it works.john elemans

1 Answers

0
votes

Yes it does. Restrictions might have been set from the server side in the web.config that looks something like this

<httpRuntime executionTimeout="3600" maxRequestLength="20480" requestValidationMode="2.0" maxQueryStringLength="2097151"/> <httpRuntime executionTimeout="3600" maxRequestLength="20480" requestValidationMode="2.0" maxQueryStringLength="2097151"/>

As base64 can be a very large data to send, try using byte array. Convert the image to byte array and send it to the server using the ajax POST request.