이 같은 갤러리에 이미지를 업로드 할 모달 데 사용 DROPZONE에서 일부 ID 전달 :Laravel
$("#addImages").click(function(event) {
event.preventDefault();
save_method = 'add';
$('input[name=_method]').val('POST');
$('#imagesModal').modal("show");
$('#imagesForm')[0].reset();
$('.modal-title').text('Add Images')
});
Dropzone.options.addImages = {
paramName: "images", // The name that will be used to transfer the file
maxFilesize: 2, // MB
};
and i already add the route and the function
public function store(Request $request)
{
$gallery = Gallery::find($request->id);
$path = 'public'.'/'.str_slug($gallery->name);
foreach ($request->images as $file) {
$image = new Image();
$image->gallery_id = $gallery->id;
$image->name = $file->getClientOriginalName();
$image->extension = $file->extension();
$image->size = $file->getClientSize();
$image->save();
// Or any custom name as the third argument
Storage::putFileAs($path, $file, $file->getClientOriginalName());
}
}
내 문제는 내가 돈이다 :
<div id="imagesModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<form name="imagesForm" id="addImages" class="form-horizontal dropzone" role="form" method="POST" action="{{ route('images.add') }}" enctype="multipart/form-data">
{{ csrf_field() }}
{{ method_field('POST') }}
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
여기 내 JQuery와 스크립트의를 내가 갤러리 ID를 전달할 수있는 방법을 알고있어 함수에 액세스 할 수 있습니까? 단추의 데이터 갤러리 ID에 넣으려는 아이디어가 있지만 어떻게 그 데이터를 전달하여 이미지와 함께 전송할 수 있습니까?
나는 그것을 시도 할 것이지만 나는 내 코드를 변경해야한다고 생각한다. 같은 id를 버튼에 사용하는 것은 잘못된 것입니다. 버튼이 foreach에 있기 때문에 먼저 그것을 알아 내야합니다. 그래서 동일한 id를가집니다. – Ying