Javascript 无法使用XHR-laravel访问上载的文件
我使用laravel with上传带有xhr请求的文件 但是,我无法使用访问上载的文件Javascript 无法使用XHR-laravel访问上载的文件,javascript,php,laravel,xmlhttprequest,Javascript,Php,Laravel,Xmlhttprequest,我使用laravel with上传带有xhr请求的文件 但是,我无法使用访问上载的文件 Input::file('name') // or eaither Input::get('name') 我两个都得到空值 如何使用xhr请求访问上载的文件 以下是我的JS代码: var sizeBox = document.getElementById('sizeBox'), // container for file size info progress = document.getEleme
Input::file('name') // or eaither
Input::get('name')
我两个都得到空值
如何使用xhr请求访问上载的文件
以下是我的JS代码:
var sizeBox = document.getElementById('sizeBox'), // container for file size info
progress = document.getElementById('progress'); // the element we're using for a progress bar
var uploader = new ss.SimpleUpload({
button: 'upload-btn', // file upload button
url: '{{action('filesController@postPicUpload')}}', // server side handler
name: 'myfile', // upload parameter name
progressUrl: 'uploadProgress.php', // enables cross-browser progress support (more info below)
responseType: 'json',
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
maxSize: 1024, // kilobytes
hoverClass: 'ui-state-hover',
focusClass: 'ui-state-focus',
startXHR: function(){
console.log('startXHR');
},
startNonXHR: function(){
console.log('startNonXHR');
},
disabledClass: 'ui-state-disabled',
onSubmit: function(filename, extension) {
this.setFileSizeBox(sizeBox); // designate this element as file size container
this.setProgressBar(progress); // designate as progress bar
},
onComplete: function(filename, response) {
console.log(response);
if (!response) {
alert(filename + 'upload failed');
return false;
}
// do something with response...
}
});
});
以下是我的行动:
public function postPicUpload(){
$file = Input::file('myfile');
$file->move('imgs/'.date('Y/n/j/', time()),$file->getClientOriginalName());
}
有什么帮助吗 在普通表单中也有同样的问题,我忘了添加表单数据
enctype="multipart/form-data"
你试过输入::hasFile('myfile')吗?是的,我试过了,但没有lucknot工作,实际上我用XHR流计算出了我的上传脚本。