Can anyone explain why files cant be uploaded using AJAX?

前端 未结 4 714
北荒
北荒 2021-01-22 01:06

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).

Ca

4条回答
  •  一整个雨季
    2021-01-22 01:28

    They can. It is XMLHttpRequest that can't be used to upload files. (But Ajax is more than 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.

提交回复
热议问题