我正在开展涉及文件上传的项目。我正在使用DropzoneJS和Laravel来完成这个项目。一切似乎都很好。
我想保存订单文件。我想按顺序传递图像顺序并保存图像文件。
我的代码:
var baseUrl = "{{ url('/') }}";
var token = "{{ Session::getToken() }}";
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(".dropzone", {
url: baseUrl + "/upload",
params: {
_token: token
}
});
Dropzone.options.myAwesomeDropzone = {
paramName: "flyers",
acceptedFiles: "image/*",
enqueueForUpload: true,
forceFallback: false,
dictDefaultMessage: "Drop files here to upload",
autoProcessQueue: false,
uploadMultiple: false,
maxFilesize: 2, // MB
addRemoveLinks: true,
accept: function(file, done) {
},
};
我的控制器
public function album()
{
$file = Input::file('file');
$destinationPath = 'uploads';
$filename = $file->getClientOriginalName();
$uploadSuccsess = Input::file('file')->move($destinationPath, $filename);
if( $uploadSuccsess ) {
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}