Ajax 文件上传 [英] Ajax file upload

查看:14
本文介绍了Ajax 文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Ajax 和 php 上传文件.我有一个带有 <input type="file"> 标签的表单.我希望当用户浏览文件并单击提交时,无需刷新即可上传文件.我该怎么做?是否发生刷新都没有关系,但我想在 ajax 的帮助下上传文件.

I want to upload a file using Ajax and php. I have a form with <input type="file"> tag. I want when user browses a file and clicks on submit, the file to be uploaded without a refresh. How should I do this ? It does't matter if refresh occur but i want to upload file with help of ajax.

推荐答案

  • 使用隐藏的 iframe 并将表单的目标设置为该 iframe 的名称.这样,提交表单时,只会刷新 iframe.
  • 为 iframe 的加载事件注册一个事件处理程序以解析响应.
  • 关于我的博客文章的更多详细信息:http://blog.manki.in/2011/08/ajax-fie-upload.html

    More details on my blog post: http://blog.manki.in/2011/08/ajax-fie-upload.html

    这篇关于Ajax 文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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