0
A
回答
0
有很好的教程http://www.phpletter.com/DOWNLOAD/
阅读和理解它会帮助你。
不管我的代码,但似乎很好的方式。
function ajaxFileUpload(){
//starting setting some animation when the ajax starts and completes
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
/*
prepareing ajax file upload
url: the url of script file handling the uploaded files
fileElementId: the file type of input element id and it will be the index of $_FILES Array()
dataType: it support json, xml
secureuri:use secure protocol
success: call back function when the ajax complete
error: callback function when the ajax failed
*/
$.ajaxFileUpload
(
{
url:'doajaxfileupload.php',
secureuri:false,
fileElementId:'fileToUpload',
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.msg);
}
}
},
error: function (data, status, e)
{
alert(e);
}
}
)
return false;
}
+0
教程链接将您从日本发送到不相关的网站。链接不好。 – OzzyTheGiant
0
您现在可以使用JavaScript FormData()对象来执行此操作。我相信它适用于除IE9及以下的所有应用程序。
<form>
<input type="file" id="file" name="file">
<button onclick="upload()">Upload</button>
</form>
和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);
}
});
}
相关问题
- 1. 通过AJAX的jQuery
- 2. jQuery的通过AJAX
- 3. jQuery的通过AJAX
- 4. jQuery的:通过Ajax
- 5. 通过jQuery/AJAX
- 6. jQuery的 - 通过Ajax请求
- 7. jQuery Mobile的:通过AJAX
- 8. 通过的jQuery/AJAX和JSON
- 9. JQuery的滚轮,通过AJAX
- 10. Submiting通过JSON/AJAX/jQuery的
- 11. 通过https的jQuery ajax
- 12. 如何通过jQuery的AJAX
- 13. 通过AJAX后(jQuery的)
- 14. jQuery的可以通过AJAX
- 15. JQuery的:通过AJAX调用
- 16. jQuery的:对通过Ajax
- 17. 如何通过AJAX/JQuery的
- 18. jQuery datepicker问题通过ajax
- 19. 通过jQuery加载javascript ajax
- 20. rails通过jquery插入ajax
- 21. jquery ajax通过多个值
- 22. 通过jquery更新viewModels ajax
- 23. 通过JQuery/Ajax传递值
- 24. jQuery Ajax POST不通过
- 25. jQuery jTable通过ajax闪烁
- 26. “过滤器”JSON通过Ajax(jQuery)
- 27. Ajax来的Rails通过jQuery的阵列
- 28. Spring Roo的:通过AJAX或jQuery的
- 29. 与装载HTML/jQuery的通过Ajax
- 30. 通过jQuery AJAX请求的JSON数据
[何灿我上传 - 文件 - 异步与 - jQuery的(http://stackoverflow.com/questions/166221/how- can-i-upload-files-asynchronously-with-jquery) – mithunsatheesh