我正在尝试构建一个表单,以异步方式将图像上传到我的网站。它适用于较新的浏览器,然后AJAX更新我的图像列表而不刷新整个页面。
我遇到的问题是它不适用于IE8& IE9(可能还有其他人),因为那些浏览器不支持" FormData"。我需要一个用户上传图像的替代方案(带有额外的隐藏表单输入字段),上传完成后图像列表应该更新 - 没有整个页面刷新。
这基本上是我到目前为止所拥有的:
<div class="imagelist">
... list of images here should be updated by ajax after each upload...
</div>
<form name="uploadform" id="uploadform" method="post" action="/edit-images/uploadimage.php" enctype="multipart/form-data">
<input type="hidden" name="itemimagesid" value="<?php echo $itemid; ?>" />
<input type="hidden" name="itemtype" value="new" />
<input type="file" name="imagefile" id="imagefile" onchange="uploadFile()">
</form>
<script type="text/javascript">
function uploadFile() {
if (!window.FormData || window.FormData === undefined) { // old crappy browsers that can't use ajax/file submit.
$('#uploadform').append("<input type='hidden' name='oldbrowser' value='1'>");
...
[ need a solution here ]
...
return;
}
}
</script>
我需要在2016年运行的东西。我有使用jQuery版本1.11.2的bootstrap 3.3.2。我已经搜索了stackoverflow,但没有一个解决方案有效。我已经尝试了jQuery Form Plugin&#34;,它什么都没做,甚至没有初始化 - 可能是因为我的jQuery版本对于那个脚本来说太新了。希望今天有更好的解决方案。
答案 0 :(得分:0)
没关系,我能够找出iframe黑客。