2

我想将图像转换为 base64 格式,然后将其上传到服务器上,但 base64 字符串太大,以至于它在网络上给我错误,该参数未收到。任何想法使用下面的 web 服务将完整的字符串发送到服务器?这是我尝试过的以下服务。

var xhrAddclient = Titanium.Network.createHTTPClient();
    xhrAddclient.open('POST', webservice_url);
    xhrAddclient.send({
        method : "addclient",
        image : base64string,
    });

    xhrAddclient.setTimeout(10000);

    xhrAddclient.onerror = function() {
        showAlertBox('Service timed out. Please try again.');

    };

    xhrAddclient.onload = function() {
        showAlertBox("Client added successfully.");


    };
4

1 回答 1

0

在这里查看:http ://www.smokycogs.com/blog/titanium-tutorial-how-to-upload-a-file-to-a-server/

在这里:https ://wiki.appcelerator.org/display/guides/File+Uploads+and+Downloads#FileUploadsandDownloads-Fileupload

要不就:

xhr.setRequestHeader("Content-type", "multipart/form-data");
xhr.send(file);
于 2013-01-06T14:32:42.457 回答