Ошибка отправки фото из админки
при отправке формы из админки, для публикации постов, мне выдает ошибку в консоли
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
app.js:1 TypeError: Cannot read property 'hasOwnProperty' of undefined
at t.value (app.js:1)
at o.<anonymous> (app.js:1)
at o.t._render (app.js:1)
at o.r (app.js:1)
at fn.get (app.js:1)
at fn.run (app.js:1)
at ln (app.js:1)
at Array.<anonymous> (app.js:1)
at Gt (app.js:1)
Vt @ app.js:1
app.js:1 TypeError: Cannot convert undefined or null to object
at t.value (app.js:1)
at keydown (app.js:1)
at qt (app.js:1)
at HTMLFormElement.n (app.js:1)
at HTMLFormElement.Xr.i._wrapper (app.js:1)
Vt @ app.js:1
app.js:1 TypeError: Cannot read property 'hasOwnProperty' of undefined
at t.value (app.js:1)
at o.<anonymous> (app.js:1)
at o.t._render (app.js:1)
at o.r (app.js:1)
at fn.get (app.js:1)
at fn.run (app.js:1)
at ln (app.js:1)
at Array.<anonymous> (app.js:1)
at Gt (app.js:1)
Vt @ app.js:1
6api/blog:1 Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)
ui.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
app.js:1 POST https://www.monolit-zabor.ru/api/blog 422 (Unprocessable Entity)
(anonymous) @ app.js:1
t.exports @ app.js:1
t.exports @ app.js:1
Promise.then (async)
c.request @ app.js:1
r.forEach.c.<computed> @ app.js:1
(anonymous) @ app.js:1
saveProduct @ app.js:1
click @ app.js:1
qt @ app.js:1
n @ app.js:1
Xr.i._wrapper @ app.js:1
Думал ошибка в JS скриптах, но потом убедился, что это не так, открыл файл лога ошибок и обнаружил такую ошибку
[2020-10-28 10:24:11] local.ERROR: Can't write image data to path (/home/setbit/web/zabor/public/images/thumb/test.jpg) {"userId":1,"email":"[email protected]","exception":"[object] (Intervention\Image\Exception\NotWritableException(code: 0): Can't write image data to path (/home/setbit/web/zabor/public/images/thumb/test.jpg) at /home/setbit/web/zabor/vendor/intervention/image/src/Intervention/Image/Image.php:143) [stacktrace]
Я так понимаю ему не нравится путь до файла, или мой контроллер страницы, или конетроллер отправки картинок. Проверил права доступа к папке, стоят полные. Вот собственно метод отправки картинки.
protected $path = '/public/images';
public function makeImage($image, $slug = null)
{
$extension = $image->getClientOriginalExtension();
$imageThumbsPath = base_path().$this->path.'/thumb/';
$imageFullPath = base_path().$this->path.'/full/';
if(!file_exists($imageThumbsPath)) mkdir($imageThumbsPath,0750,true);
if(!file_exists($imageFullPath)) mkdir($imageFullPath,0750,true);
$imageName = $slug.'.'.$extension;
$thumb = Image::make($image)
->fit(600, 450, function ($constraint) {
$constraint->upsize();
});
$thumb->save($imageThumbsPath.$imageName);
$full = Image::make($image)
->fit(1280, 720, function ($constraint) {
$constraint->upsize();
});
$full->save($imageFullPath.$imageName);
return $imageName;
}
Метод сохранения для контроллера страницы
public function store(Request $request, PageRequest $pageRequest)
{
if($request->hasFile('image')) $image = $this->image->makeImage($request->file('image'), $request->slug);
elseif (!empty($request->image)) $image = $request->image;
else $image = "";
($request->published == 'true' || $request->published == 1) ?
$published = 1 :
$published = 0;
($request->price == 'null' || $request->price == "") ? $price = "" : $price = $request->price;
$page = Page::create( $request->except([
'image',
'price',
'published'
]) + [
'image' => $image,
'price' => $price,
'published' => $published
]);
return response()->json(['success'=>'ok','id'=>$page->id]);
}
До этого сайт переезжал с локалки на хост, возможно где то не совпали пути для папок сохранения или какие то настройки?