50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?php
|
|
// Fallback für Bild-Upload ohne GD Extension
|
|
// Fügen Sie dies temporär in UserNailPolishController.php ein
|
|
|
|
// Ersetzen Sie den Bildverarbeitungs-Code in der store() Methode:
|
|
|
|
/*
|
|
// Original-Code (mit GD):
|
|
if ($request->hasFile('image') && $request->file('image')->isValid()) {
|
|
$image = $request->file('image');
|
|
$filename = 'nail_polish_' . time() . '_' . uniqid() . '.jpg';
|
|
$path = 'nail_polishes/' . $filename;
|
|
|
|
$manager = new ImageManager(new Driver());
|
|
$img = $manager->read($image);
|
|
$img->resize(400, 400, function ($constraint) {
|
|
$constraint->aspectRatio();
|
|
$constraint->upsize();
|
|
});
|
|
|
|
$imageData = $img->toJpeg(80)->toString();
|
|
Storage::disk('public')->put($path, $imageData);
|
|
$nailPolish->image_path = $path;
|
|
}
|
|
*/
|
|
|
|
// Fallback-Code (ohne GD):
|
|
if ($request->hasFile('image') && $request->file('image')->isValid()) {
|
|
$image = $request->file('image');
|
|
|
|
// Prüfe Dateigröße (max 2MB)
|
|
if ($image->getSize() > 2 * 1024 * 1024) {
|
|
return back()->with('error', 'Das Bild darf maximal 2MB groß sein.')->withInput();
|
|
}
|
|
|
|
// Prüfe Dateityp
|
|
$allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'];
|
|
if (!in_array($image->getMimeType(), $allowedTypes)) {
|
|
return back()->with('error', 'Nur JPG, PNG und GIF Dateien sind erlaubt.')->withInput();
|
|
}
|
|
|
|
// Speichere Original-Bild ohne Verarbeitung
|
|
$filename = 'nail_polish_' . time() . '_' . uniqid() . '.' . $image->getClientOriginalExtension();
|
|
$path = 'nail_polishes/' . $filename;
|
|
|
|
Storage::disk('public')->put($path, file_get_contents($image));
|
|
$nailPolish->image_path = $path;
|
|
}
|
|
?>
|