javascript - 如何将上传的图像转换为字节数组javascript
问题描述
i want to upload images to the server using ajax post request , here my question was how to convert image to a byte array for sending image to the server as multipart how can i achieve this.
here I posted what I tried:
<div class="col-sm-6 col-md-4 form-group">
<label>Attachement</label>
<input id="other_fileUpload_create" type="file" class="form-pcontrol">
</div>
阿贾克斯:
var formData = new FormData();
$.ajax({
url: baseURL + '/misportal/ptwRest/saveIsolation',
type: "POST",
contentType: false,
processData: false,
data: function() {
// var inputs = $('#IsolationFO').serializeArray();
//here i got image path instead of byte array
formData.append("Image",$('#other_fileUpload_create').val());
return formData;
}(),
解决方案
推荐阅读
- google-apps-script - 函数“setFormula()”不会产生工作表公式
- c# - AVALONIA:将按钮绑定到在 Datagrid 中添加信息的方法
- node.js - ReactJs 安装 react-html-table-to-excel 时出错
- c# - 如何用 Join() 替换 ToList()
- visual-studio - Visual Studio 更改属性和方法列表的顺序
- sql - 如何在 FROM 语句中使用变量来更改服务器
- flutter - Flutter/Dart:扫描本地网络以获取连接设备的 IP 和主机名
- ssh - 如何在运行 ansible-playbook 时发送公钥?
- javascript - React 将键盘事件导航添加到网站
- html - 如何仅在底部向曲线添加描边?