我正在使用一个浏览器插件,它接收来自扫描仪的输入并返回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>