neonail-database/fix-upload-limits.php
2025-08-10 18:09:07 +02:00

134 lines
4.4 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// Fix: Upload-Limits für Bild-Upload
echo "📸 Fix: Upload-Limits für Bild-Upload\n";
echo "===================================\n\n";
// 1. Aktuelle PHP-Upload-Limits prüfen
echo "1. 🔍 Aktuelle PHP-Upload-Limits:\n";
$limits = [
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'max_file_uploads' => ini_get('max_file_uploads'),
'memory_limit' => ini_get('memory_limit'),
'max_execution_time' => ini_get('max_execution_time'),
'max_input_time' => ini_get('max_input_time')
];
foreach ($limits as $setting => $value) {
echo " - $setting: $value\n";
}
// 2. Konvertiere zu Bytes für Vergleich
function convertToBytes($sizeStr) {
$sizeStr = strtolower(trim($sizeStr));
$last = strtolower($sizeStr[strlen($sizeStr)-1]);
$size = (int)$sizeStr;
switch($last) {
case 'g': $size *= 1024;
case 'm': $size *= 1024;
case 'k': $size *= 1024;
}
return $size;
}
$uploadMaxBytes = convertToBytes($limits['upload_max_filesize']);
$postMaxBytes = convertToBytes($limits['post_max_size']);
$requiredBytes = 10 * 1024 * 1024; // 10MB
echo "\n2. 📊 Größenvergleich:\n";
echo " - Upload max filesize: " . number_format($uploadMaxBytes) . " Bytes\n";
echo " - Post max size: " . number_format($postMaxBytes) . " Bytes\n";
echo " - Benötigt für 10MB: " . number_format($requiredBytes) . " Bytes\n";
if ($uploadMaxBytes < $requiredBytes) {
echo " ⚠️ upload_max_filesize ist zu klein für 10MB Uploads\n";
} else {
echo " ✅ upload_max_filesize ist ausreichend\n";
}
if ($postMaxBytes < $requiredBytes) {
echo " ⚠️ post_max_size ist zu klein für 10MB Uploads\n";
} else {
echo " ✅ post_max_size ist ausreichend\n";
}
// 3. .htaccess für Upload-Limits erstellen
echo "\n3. 🔧 .htaccess Upload-Limits erstellen...\n";
$htaccessContent = "
# Upload-Limits für Bild-Upload
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_file_uploads 20
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
";
if (file_exists('public/.htaccess')) {
$currentHtaccess = file_get_contents('public/.htaccess');
// Prüfe ob Upload-Limits bereits vorhanden sind
if (strpos($currentHtaccess, 'upload_max_filesize') === false) {
// Füge Upload-Limits hinzu
$newHtaccess = $currentHtaccess . "\n" . $htaccessContent;
file_put_contents('public/.htaccess', $newHtaccess);
echo " ✅ Upload-Limits zu .htaccess hinzugefügt\n";
} else {
echo " Upload-Limits bereits in .htaccess vorhanden\n";
}
} else {
echo " ❌ public/.htaccess nicht gefunden\n";
}
// 4. Test-Upload-Funktionalität
echo "\n4. 🧪 Test Upload-Funktionalität...\n";
// Prüfe GD Extension
if (extension_loaded('gd')) {
echo " ✅ GD Extension geladen\n";
} else {
echo " ❌ GD Extension nicht geladen - Bildverarbeitung nicht möglich\n";
}
// Prüfe Storage-Verzeichnis
$storagePath = 'storage/app/public/nail_polishes';
if (is_dir($storagePath)) {
echo " ✅ Storage-Verzeichnis existiert: $storagePath\n";
} else {
echo " ⚠️ Storage-Verzeichnis existiert nicht: $storagePath\n";
mkdir($storagePath, 0755, true);
echo " ✅ Storage-Verzeichnis erstellt\n";
}
// Prüfe Schreibrechte
if (is_writable($storagePath)) {
echo " ✅ Storage-Verzeichnis beschreibbar\n";
} else {
echo " ❌ Storage-Verzeichnis nicht beschreibbar\n";
}
// 5. Laravel Storage Link prüfen
echo "\n5. 🔗 Laravel Storage Link prüfen...\n";
$publicStoragePath = 'public/storage';
if (is_link($publicStoragePath)) {
echo " ✅ Storage Link existiert\n";
} else {
echo " ⚠️ Storage Link existiert nicht\n";
if (file_exists('public/storage')) {
echo " public/storage ist ein Verzeichnis, kein Link\n";
} else {
echo " public/storage existiert nicht\n";
}
}
echo "\n✅ Upload-Limits Fix abgeschlossen!\n";
echo "🔗 Testen Sie jetzt: https://neonail.vogt.de.com/create-nail-polish\n";
echo "📝 Versuchen Sie ein Handy-Foto hochzuladen (bis 10MB)\n";
echo "\n📋 Falls Upload immer noch fehlschlägt:\n";
echo "- Prüfen Sie die Browser-Entwicklertools (F12) für Details\n";
echo "- Schauen Sie in storage/logs/laravel.log für Laravel-Fehler\n";
echo "- Prüfen Sie die Apache-Logs für Server-Fehler\n";
?>