我想用jQuery异步上传文件。
$(document).ready(function () {$("#uploadbutton").click(function () {var filename = $("#file").val();
$.ajax({type: "POST",url: "addFile.do",enctype: 'multipart/form-data',data: {file: filename},success: function () {alert("Data Uploaded: ");}});});});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script><span>File</span><input type="file" id="file" name="file" size="10"/><input id="uploadbutton" type="button" value="Upload"/>
我只得到文件名,而不是正在上传的文件。我能做些什么来解决这个问题?