Commit 13f4c712 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: avatar upload 500 — increase PHP upload limits + better errors

Add upload_max_filesize=10M to PHP config (default 2M was rejecting
compressed images). Add fileinfo extension explicitly. Improve error
messages in avatar.php to report the actual failure reason.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 73495fd9
FROM php:8.3-apache
RUN apt-get update && apt-get install -y libpq-dev libcurl4-openssl-dev \
&& docker-php-ext-install pdo pdo_pgsql pgsql curl \
&& docker-php-ext-install pdo pdo_pgsql pgsql curl fileinfo \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN echo "upload_max_filesize = 10M\npost_max_size = 12M\nmax_file_uploads = 5" > /usr/local/etc/php/conf.d/uploads.ini
RUN a2enmod rewrite headers
ENV APACHE_DOCUMENT_ROOT=/var/www/html
......
......@@ -15,8 +15,12 @@ $token = requireAuth();
$userId = getUserId($token);
if (!$userId) jsonError('Invalid user', 401);
if (!isset($_FILES['avatar']) || $_FILES['avatar']['error'] !== UPLOAD_ERR_OK) {
jsonError('No file uploaded');
if (!isset($_FILES['avatar'])) {
jsonError('No file in request. Check upload_max_filesize (' . ini_get('upload_max_filesize') . ')');
}
if ($_FILES['avatar']['error'] !== UPLOAD_ERR_OK) {
$errors = [1 => 'File exceeds server limit', 2 => 'File exceeds form limit', 3 => 'Partial upload', 4 => 'No file sent', 6 => 'No tmp dir', 7 => 'Write failed'];
jsonError($errors[$_FILES['avatar']['error']] ?? 'Upload error ' . $_FILES['avatar']['error']);
}
$file = $_FILES['avatar'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment