任何人都可以解释为什么文件不能被使用AJAX上传? [英] Can anyone explain why files cant be uploaded using AJAX?

查看:126
本文介绍了任何人都可以解释为什么文件不能被使用AJAX上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了很多文章等试图解释为什么一个文件(如附件等)无法通​​过AJAX上传(ATLEAST没有一些招数在幕后)。

I have read many articles etc that attempt to explain why a file (e.g. attachment etc) cannot be uploaded via AJAX (atleast without some 'tricks' behind the scene).

谁能解释清楚,简单地说,技术原因,AJAX这一功能?

Can anyone explain CLEARLY and SIMPLY, the technological reasons for this 'feature' of AJAX?

推荐答案

他们可以。它是XMLHtt prequest不能用于上载文件。 (但是,Ajax是超过XHR)

They can. It is XMLHttpRequest that can't be used to upload files. (But Ajax is more than XHR)

这是因为,出于安全原因,JavaScript不能从文件系统中读取,因此它不能用手去XHR文件。

This is because, for security reasons, JavaScript can't read from the file system, so it can't get the file to hand to XHR.

这篇关于任何人都可以解释为什么文件不能被使用AJAX上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆