如何轻松上传文件,而无需提交表单(使用jQuery + AJAX) [英] How to easily upload files without form submission (with jQuery + AJAX)

查看:345
本文介绍了如何轻松上传文件,而无需提交表单(使用jQuery + AJAX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有某种形式的处理code的处理标准文本输入,并上传的文件(通过$ _FILES数组)

So I have some form processing code which processes the standard text inputs and also uploaded files (through the $_FILES array)

我想已经提交通过AJAX做

I want to have the submission done through AJAX

请问jQuery的岗位()。方法还通过这些东西通过 - > $ _FILES或做我需要做一些特别的东西。

Will jQuery's post(). method still pass that stuff through -> $_FILES or do I need to do something special?

推荐答案

阿贾克斯(定义,使用JavaScript)不能完成文件上传,因为JavaScript不能访问本地文件系统。有解决方法,似乎使用Ajax,比如iframe或使用Flash。

Ajax (as defined, using JavaScript) cannot perform file uploads, as JavaScript cannot access the local filesystem. There are workarounds that seem to use Ajax, such as an iframe or using Flash.

围绕谷歌亨特,你会发现一些东西。还有更多的库(YUI例如),它们把这个在一起。

Hunt around Google, you'll find something. There are more libraries (YUI for example) that are putting this together.

这篇关于如何轻松上传文件,而无需提交表单(使用jQuery + AJAX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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