【发布时间】:2020-09-10 16:23:48
【问题描述】:
我有这个简单的 HTML 代码:
<form id="filedrop"
class="dropzone"
action="{{ route('store.womenoffer.photo', ['id' => $id]) }}"
enctype="multipart/form-data"
method="post">
{{ csrf_field() }}
</form>
我想添加处理事件。所以我尝试了一些事情:
$(function () {
var myDropzone = $("#filedrop");
myDropzone.on("success", function (file) {
alert('Hello World');
});
})
还有这个:
Dropzone.options.filedrop = {
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 2, // MB
accept: function(file, done) {
accept: function(){
alert('Hello World');
},
success: function(){
alert('Hello World 1');
}
};
所有照片均已正确上传,但活动无效。我的后端代码如下所示:
$name = $this->uploadImg($request->file('file'), 'small');
if($name){
Photo::create([
'name' => $name,
'user_id' => Auth::user()->id,
'women_id' => $id
]);
return response()->json(['success' => $name]);
【问题讨论】:
标签: javascript jquery dropzone.js dropzone