why 500 (Internal Server Error)?
my route for upload image
Route::post('tech-img', 'ImageController@imageCropPost');
My Controller for upload image
public function imageCropPost(Request $request)
{
$data = $request->image;
$id=$request->id;
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
$image_name= time().'.png';
$path = public_path() . "/upload/" . $image_name;
file_put_contents($path, $data);
$update=DB::table('technologys')
->where('id','=', $id)
->update(['img' => $image_name]);return $update;}`
My Ajax for upload image
function uptecimage(id){
var id=id.id;
$('#inputimg').val(id);}
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
$('.upload-result').on('click', function (ev) {
$uploadCrop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
var id= document.getElementById('inputimg').value;
$.ajax({
url: "/tech-img",
type: "POST",
data: {"image":resp, "id":id},
success: function (data) {
console.log(data);
/*
html = '<img src="' + resp + '" />';
$("#upload-demo-i").html(html);
*/
}
});
});
});
My blade Templet OR HTML code for upload image
<button data-toggle="modal" href='#upimage' onclick="uptecimage(this)" id=""><i class="fa fa-camera"></i></button>
<div class="modal fade" id="upimage">
<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">Image Upload</h4>
</div>
<div class="modal-body">
<input type="hidden" name="inputimg" id="inputimg" class="form-control" value="">
<div id="upload-demo" style="width:350px"></div>
<strong>Select Image:</strong>
<br/>
<input type="file" id="upload">
<br/>
<button class="btn btn-success upload-result">Upload Image</button>
</div>
</div>
</div>
</div>
When press Upload Image button then error Failed to load resource: the server responded with a status of 500 (Internal Server Error)
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2S9LJ7d
via IFTTT
Aucun commentaire:
Enregistrer un commentaire