Use formdata combined with snoopy for request forwarding to implement non-form and non-iframe asynchronous file upload functions.
JS code:
document.getElementById('#file').change = function (e) {
var data = new FormData();
//Set parameters
data.append('nick', 'Bangyan');
data.append('session_id', '6fc373162b5e8a78a255777e0108a0b3');
data.append('file', e.currentTarget.files[0 ]);
}
PHP code:
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