Dans ma page web, j'utilise summernote pour ajouter une image et des vidéos. When I upload the file, this one is added to the server folder but it can not be found on the server. I get this error: The requested URL /backend/imagesummernote/jlgRjT0uFzlZnRR9gSfO1igMRC4VApYPlNt7g5tJ.png was not found on this server
this is the upload request:
public function upload(Request $request)
{
try {
$input = \Input::all();
$file = \Input::file('image');
$path = \Storage::disk('public')->put('imagesummernote', $file);
return \Response::json(['status' => 1, 'path' => $path], 200);
} catch (\Exception $e) {
\Log::debug($e->getMessage());
return \Response::json(['status' => 0, 'errors' => 'Unexpected error! '], 400);
}
}
And the JQuery:
function uploadImage(image) {
var data = new FormData();
data.append("image", image);
$.ajax({
url: "",
cache: false,
contentType: false,
processData: false,
data: data,
type: "post",
success: function (url) {
if (url.status == 1) {
var image = $('<img>').attr('src','/backend/'+url.path);
$('#summernote').summernote("insertNode", image[0]);
}
},
error: function (data) {
console.log(data);
}
});
}
$('#summernote').summernote({
toolbar: [
// [groupName, [list of button]]
['fontsize', ['fontsize']],
['fontname', ['fontname']],
['style', ['bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'clear']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['color', ['color']],
['float', ['floatLeft', 'floatRight', 'floatNone']],
['remove', ['removeMedia']],
['table', ['table']],
['insert', ['link', 'unlink', 'picture', 'video', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
],
height: ($(window).height() - 300),
callbacks: {
//onImageUpload: function (image)
onImageUpload: function (image) {
uploadImage(image[0]);
}
}
});
I am a beginner in laravel. Is there a way to add the file to the folder and display in the web page?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire