<div class="modal" id="modal-image" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" >
   <div class="modal-dialog modal-md">
      <div class="modal-content">
          <div class="modal-content" style="border-left: #6495ED 6px solid;">
     
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> &times; </span> </button>
      <h4 class="modal-title">upload bukti setor (slip setoran)</h4>   
   </div>     
   
 
   	<div class="modal-body modal-md">

			<div class="box">
			<div class="box-body">
				<?php if(count($errors) > 0): ?>
				<div class="alert alert-danger">
					<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<?php echo e($error); ?> <br/>
					<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				</div>
				<?php endif; ?>
 


				<form action="/wawan/upload/proses" method="POST" enctype="multipart/form-data">
<!--				<form method="POST" enctype="multipart/form-data"> -->
					<?php echo e(csrf_field()); ?>

					

                        <div class="progress" style="display:none">
                            <div class="progress-bar" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="">
                                <span class="sr-only"></span>
                            </div>
                        </div>
  
					<input type="hidden" id="id2" name="id2">

					<div class="form-group">
						<p>File Gambar (size:500x500 pixel, ukuran file tidak melebihi 1MB)</p>
						<p></p>
						<div class="col-sm-6">
							<input type="file" name="file" id="file" value="" required autocomplete="off">
						</div>
					</div>
					<br>
					
					<img class="image-fluid" id="img" name="img">
					
					<br><br><br>
					<br>
					<br>
					<button type="submit" id="submit-upload" class="btn btn-primary">upload</button>

				</form>

			</div>
	</div>
	

		</div>
	</div>
</div>
</div>
</div>

<script type="text/javascript">
 //   $(document).on('ajaxComplete ajaxReady', function () {
 //       $.ajaxSetup({
 //           headers: {
//                'X-CSRF-Token': $('input[name="_token"]').val()
 //           }
//        });
        
        //$('#modal-image').on("submit", function (e) {
        $('#submit-upload').on("submit", function (e) {
            $("progress").show();
            var formData = new FormData(this);
            var formURL = $("#modal-image").attr("action");
            $.ajax(
                    {
                        url: formURL,
                        type: "POST",
                        data: formData,
                        contentType: false,
                        processData: false,
                        success: function (data, textStatus, jqXHR)
                        {
                            var data = jqXHR.responseJSON;
                            window.location.href = data.url;
                        },
                        error: function (jqXHR, textStatus, errorThrown)
                        {
                            var data = jqXHR.responseJSON;
                            errorsHtml = '<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><ul>';
 
                            $.each(data, function (key, value) {
                                errorsHtml += '<li>' + value[0] + '</li>';
                            });
                            errorsHtml += '</ul></di>';
                            
                           $(".modalError").html(errorsHtml);
                        },
                        xhr: function () {
                            var xhr = $.ajaxSettings.xhr();
                            xhr.upload.onprogress = function (e) {
                                $(".progress-bar").attr("style", "width:" + Math.floor(e.loaded / e.total * 100) + "%");
                                $(".progress-bar").html(Math.floor(e.loaded / e.total * 100) + "%");
                            };
                            return xhr;
                        },
                    });
            e.preventDefault();
            e.unbind();
        });
//    });
</script>                            

<?php /**PATH /home/myprojeq/public_html/wawan/resources/views/setor/image.blade.php ENDPATH**/ ?>