我使用的悬浮窗文件上传,当我返回成功从控制器/错误,我怎么证明它在我的视图文件..展会上悬浮窗文件成功/错误信息上传
查看文件,
<div class="box-body">
@if ($errors->count() > 0)
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ $message = 'Please select csv file only.' }}
</div>
@endif
{!! Form::open([ 'url' => 'admin/reports','class' => 'dropzone', 'id' => 'reportfile' ]) !!}
{!! csrf_field() !!}
<div class="col-md-12">
<h3 style="text-align : center">Select File</h3>
</div>
<button type="submit" class="btn btn-primary">Upload Report</button>
{!! Form::close() !!}
</div>
控制器代码
if ($request->hasFile('file')) {
$file = Input::file('file');
$validator = Validator::make(
[
'file' => $file,
'extension' => strtolower($file->getClientOriginalExtension()),
], [
'file' => 'required',
'extension' => 'required|in:csv',
]
);
if ($validator->fails()) {
return Response::json('error', 400);
}
JS码
<script>
window.onload = function() {
Dropzone.options.reportfile = {
paramName: "file",
maxFilesize: 2,
error: function (file, response) {
alert('hiii')
},
init: function() {
this.on("addedfile", function (file) {
alert("Added file.");
});
},
accept: function (file, done) {
alert('hi')
if (file.name == "justinbieber.jpg") {
done("Naha, you don't.");
}
}
};
};
</script>
工作甚至没有警告...任何帮助是非常appreciated..Thanks
这是否显示您的控制台中的任何错误? –
是它在控制台响应选项卡上显示“错误”字符串。在控制台中显示“400错误请求”,因为我返回了400错误请求错误。 – Aamir
加入;在'alert('hi');' – paranoid