jQuery的:通过发送PDF服务器阿贾克斯 [英] jQuery:Sending pdf to server via ajax
本文介绍了jQuery的:通过发送PDF服务器阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用ajax.But我找不到任何例子或者codeS发送pdf文件到服务器
I want to send a pdf file to server using ajax.But I couldn't find any examples or codes for
这problem.How我可以得到解决?请帮我
this problem.How can i get the solution?Please help me
推荐答案
您可以使用JavaScript FORMDATA()对象现在做到这一点。我相信它在一切,除了IE9和下文。
You can use the javascript FormData() object to do this now. I believe it works in everything except IE9 and below.
<form>
<input type="file" id="file" name="file">
<button onclick="upload()">Upload</button>
</form>
和JavaScript的..
And the javascript..
function upload() {
var fd = new FormData(),
myFile = document.getElementById("file").files[0];
fd.append( 'file', myFile);
$.ajax({
url: 'http://example.com/script.php',
data: fd,
processData: false,
contentType: false,
type: 'POST',
success: function(data){
console.log(data);
}
});
}
这篇关于jQuery的:通过发送PDF服务器阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文