cra*_*231 3 javascript php ajax internet-explorer-8
我试图找到示例代码在IE8中异步上传文件(通过Ajax).上传进度也不错,但不是强制性的.我喜欢PHP代码,能够处理文件服务器端.我不断遇到使用FormData的其他浏览器的示例,但我无法使用它.可以请任何一个人指出我正确的方向吗?
这是一个关于这个主题的好教程: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>
Run Code Online (Sandbox Code Playgroud)
JS:
function redirect()
{
//'my_iframe' is the name of the iframe
document.getElementById('my_form').target = 'my_iframe';
document.getElementById('my_form').submit();
}
Run Code Online (Sandbox Code Playgroud)
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";
}
Run Code Online (Sandbox Code Playgroud)
那会让你开始=)
| 归档时间: |
|
| 查看次数: |
11747 次 |
| 最近记录: |