IE8异步文件上传 [英] IE8 Async file upload

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

问题描述

我想找到例如code到(通过Ajax)asyncronously上传文件在IE8。同时上传进度将是很好的,但不是强制性的。标识如PHP code到能够处理的文件服务器端。我把整个示例使用FORMDATA其他浏览器来了,但我不能使用它。难道任何机构请点我在正确的方向?

I am trying to find example code to upload files asyncronously (via Ajax) in IE8. Also upload progress would be nice, but not mandatory. Id like PHP code to be able to deal with the file server side. I keep coming across examples for other browsers using FormData, but I cannot use that. Could any body please point me in the right direction?

推荐答案

这是关于这个问题的一个很好的教程:的 http://hungred.com/how-to/tutorial-easiest-asynchronous-upload-file-ajax-upload/

This is a good tutorial on the subject: http://hungred.com/how-to/tutorial-easiest-asynchronous-upload-file-ajax-upload/

HTML:

<form id="my_form" name="form" action="upload.php" method="POST" 
enctype="multipart/form-data" >

<div id="main">
<input name="my_files" id="my_file" size="27" type="file" />
<input type="button" name="action" value="Upload" onclick="redirect()"/>
<iframe id='my_iframe' name='my_iframe' src="">
</iframe>
</div>

</form>

记者:

function redirect()
{
//'my_iframe' is the name of the iframe
document.getElementById('my_form').target = 'my_iframe';
document.getElementById('my_form').submit();
}

PHP:

$uploaddir = '/images/';
$uploadfile = $uploaddir . basename($_FILES['my_files']['name']);

if (move_uploaded_file($_FILES['my_files']['my_name'], $uploadfile)) {
echo "success";
} else {
echo "error";
}

这将让你开始=)

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

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