Level 8
Jesus, now I pulled from git and now it doesn't even work if its just in images/ wtf hostinger.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
When handling the uploading of images on my local everything works fine, but uploading the app to hostinger I run into a problem.
The problem is that if I save to a file past /images, lets say /images/collection the image doesn't display, I can simply fix this by just saving into the /images folder.
Here is my code.
public function store(Request $request)
{
$validated = $request->validate([
'name' => 'required|max:255|unique:' . Collection::class,
]);
$path = ImageController::store($request->file('image'), 'collection');
$data = new Collection;
$data->name = $request->name;
$data->image = $path;
$data->save();
}
public static function store($image, $location)
{
$filename = uniqid() . '.' . $image->getClientOriginalExtension();
// $path = $image->storeAs('public/images/'.$location, $filename);
$path = $image->storeAs('public/images', $filename);
$path = substr_replace($path, '/storage', 0, 6);
return $path;
}
Please or to participate in this conversation.