Home > php教程 > php手册 > 使用 Snoopy 代理异步文件上传

使用 Snoopy 代理异步文件上传

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:40:57
Original
854 people have browsed it

使用 formdata 结合 snoopy 做请求转发,实现非 form 形式,非 iframe 形式的异步文件上传功能。

JS 代码:
document.getElementById('#file').change = function (e) {
var data = new FormData();

//设置参数
data.append('nick', '邦彦');
data.append('session_id', '6fc373162b5e8a78a255777e0108a0b3');
data.append('file', e.currentTarget.files[0]);

}
PHP 代码:

require('Snoopy.class.php');
$action = 'http://localhost/upload.php';
$snoopy = new Snoopy();
$snoopy->_submit_type = 'multipart/form-data';
$snoopy->submit($action, $_REQUEST, $_FILES);
echo $snoopy->results;
// Downloads By http://www.bkjia.com

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template