提交< input type ="文件" />使用jQuery $ .post [英] Submit an <input type="file" /> using jQuery $.post
问题描述
我有一个< div />
标记,它包含一个文件上传< input id =filetype =file />
标签。我想使用 $。ajax()
或<$ c将 input
标签的内容贴到php页面$ c> $。post()但是如何获取输入
标签的内容,其类型为文件
?所以我可以使用jQuery ajax函数提交它?
注意:我的代码没有< form />
标签呢。我不确定是否强制上传文件。 我也看到了一些解决方法,使用< iframe>
我想知道是否可以这样做。
我不希望使用任何插件来做这件事。
不成为异步请求的一部分。换句话说,您不能使用AJAX方式发送数据。
I have a <div/>
tag which contains a file upload <input id="file" type="file"/>
tag. I want to post the contents of the input
tag to a php page using $.ajax()
or $.post()
but how do I grab the contents of the input
tag having its type as "file"
? so I can submit it using the jQuery ajax functions?
Note: My code doesn't have a <form/>
tag yet. I am not sure if its mandatory to upload files. Also i've seen some workarounds using <iframe>
I want to know if this can be done otherwise.
I don't want to use any plugins to do this.
A byte stream can't be part of an asynchronous request.
In other words, you can't send data using AJAX approaches.
这篇关于提交< input type ="文件" />使用jQuery $ .post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!