我想上传一个在React.js中使用CKEditor-5的图片,我前面的代码是:
<CKEditor
editor={ClassicEditor}
data={`<p>${label} : ${placeholder}</p>`}
config={
{
ckfinder:{
uploadUrl: "http://127.0.0.1:8000/api/upload/"
}
}
}
/>
我在“UploadController”中用Laravel写的代码:
$imgpath = Storage::disk('public')->put("images/uploads", $request->file('upload'));
return response()->json([
'default' => "http://127.0.0.1:8000/".$imgpath,
]);
在选择图像之后,图像将成功地保存在我想要的路径中。但是失败的消息出现在前面。
我必须在Laravel装一个包裹吗?我不知道我哪里错了?
发布于 2022-09-11 16:24:06
您需要以正确的JSON格式返回响应。
正确的Json响应格式是:
{
fileName: "FileName.jpg",
uploaded: 1,
url: "http://127.0.0.1:8000/".$imgpath
}https://stackoverflow.com/questions/73099726
复制相似问题