413 Request Entity Too Large on Production but it uploads on Local server
this is my code
public function upload(Request $request)
{
$folder = 'product_photo';
if ($request->hasFile('photo')) {
$file = $request->file('photo');
request()->validate([
'photo' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:6048',
]);
$cloudinaryResponse = Cloudinary::upload($file->getRealPath(), [
'folder' => $folder,
]);
$secureUrl = $cloudinaryResponse->getSecurePath();
return response()->json(['secure_url' => $secureUrl], 200);
} else {
return response()->json(['error' => 'No file uploaded'], 400);
}
}
this is the error message i get
the problem is that it works on local but on production it shows this error message
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<center>
<h1>413 Request Entity Too Large</h1>
</center>
<hr>
<center>nginx/1.24.0</center>
</body></html>
my laravel application is hosted on railway.
Please how can i solve this problem
Answers
-
HI @NgoziStephen ,
Thanks for reaching out.
413 entity large error is usually received when you try to upload an asset that is larger than 100MB but you're still using the standard
upload
method from our SDK.You would need to instead use which the SDK does support via the function
upload_large
, more details here:Please let me know how you get on.
Kind Regards,
Thomas
0