如何上传javascript变量中包含的base64编码文件?

时间:2013-03-25 20:44:02

标签: javascript ajax forms upload

我正在使用一个浏览器插件,它接收来自扫描仪的输入并返回base64编码的字符串。我正在尝试使用此字符串并将其用作表单帖子的内容。我很茫然。

var formElem = document.getElementById("fileUploadForm");
var imagedata;

Plugin.SelectedImagesCount = 1;
Plugin.SetSelectedImageIndex(0,0); // Set the 1st image as the first selected image.

Plugin.GetSelectedImagesSize(1); //jpeg
imagedata = Plugin.SaveSelectedImagesToBase64Binary();
//This is where I'd like to send the imagedata to the server

我尝试过搜索,但到目前为止我找到的唯一方法是构建自定义http来模拟表单提交。我想重用我现有的文件上传表单。

<form id="fileUploadForm" method="POST" enctype="multipart/form-data">
    <!-- Scanning -->
    <select name="docType">
        <option>1</option>
        <option>2</option>
        <option>3</option>
    </select>
    <button onClick="ScanImage(); return false;">Scan</button>
    <!-- Uploading -->
    <input id="DocUploadInput" type="file" name="RemoteFile" />
    <button onClick="fileUpload(this.form,'/UploadDocument/'); return false;">Upload</button>
</form>

0 个答案:

没有答案