javascript读取网页图片(验证码)然后发送到服务器

作者在 2017-08-02 17:38:25 发布以下内容

挺简单的

var img_url = $input_verifycode.next('img').attr('src');
var r = new XMLHttpRequest();
r.open("GET", img_url);
r.responseType = "blob";
r.onload = function(e){
	var data = new FormData();
	data.append('image_data', this.response);
	$.ajax({
		url: 'http://localhost:8088/upload.php',
		data: data,
		cache: false,
		contentType: false,
		processData: false,
		type: 'POST',
		success: function(data){
		//alert('上传成功');
		}
	});
};
r.send();

WEB开发 | 阅读 2470 次
文章评论,共0条
游客请输入验证码
浏览2798480次
文章归档