Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jeFFF's avatar
Level 3

Help with nginx config

Hello, I'm stuck with nginx config, for a project I have to upload MP4 files with a size of 100M maximum. I setup my php.ini accordingly like this :

post_max_size=100M
upload_max_file_size=100M

I configure nginx with this line added :

client_max_body_size 100M;

When I upload an image file, everything is doing great and working, but when I upload an MP4 video (17M), the output becomes this :

"video" => Illuminate\Http\UploadedFile {#1384
    -test: false
    -originalName: "Turbonegro.mp4"
    -mimeType: "application/octet-stream"
    -error: 1
    #hashName: null
    path: ""
    filename: ""
    basename: ""
    pathname: ""
    extension: ""
    realPath: "/home/site/wwwroot/public"
    aTime: 1970-01-01 00:00:00
    mTime: 1970-01-01 00:00:00
    cTime: 1970-01-01 00:00:00
    inode: false
    size: false
    perms: 00
    owner: false
    group: false
    type: false
    writable: false
    readable: false
    executable: false
    file: false
    dir: false
    link: false
  }

My video file is not put in TMP folder, and my process is not working.

What did I miss ? something in my nginx conf ? Thanks for your help with this

0 likes
1 reply
LaryAI's avatar
Level 58

It looks like you've configured both PHP and Nginx to accept file uploads of up to 100M, which is good. However, the error you're seeing (-error: 1) in the UploadedFile object indicates that the upload exceeded the upload_max_filesize directive in php.ini. This is a bit confusing since you've mentioned that the MP4 file is only 17M.

Here are a few steps to troubleshoot the issue:

  1. Double-check your php.ini settings. Make sure you have set upload_max_filesize correctly (it should be upload_max_filesize instead of upload_max_file_size). Also, ensure that you have restarted your PHP-FPM service after making changes to php.ini.

  2. Verify that you are editing the correct php.ini file. You can create a PHP file with the following content to check your configuration:

<?php
phpinfo();

Access this file through your web server to see the loaded configuration and verify the upload_max_filesize and post_max_size values.

  1. Ensure that you have reloaded or restarted Nginx after adding the client_max_body_size directive to your Nginx configuration.

  2. Check your Nginx error logs for any messages that could indicate why the file upload is failing. The error log path is usually defined in your Nginx configuration file (error_log directive).

  3. If you're using PHP-FPM, check the PHP-FPM error logs as well. There might be additional information there.

  4. Make sure that the tmp directory used by PHP for uploads (upload_tmp_dir in php.ini) is writable by the PHP process.

  5. If you're using a web application framework like Laravel, make sure that the framework's configuration isn't imposing its own file size limits.

If after checking all these steps the problem persists, you might want to provide more information about your environment, such as the specific versions of PHP and Nginx you're using, and any additional server configuration that might be affecting file uploads.

Please or to participate in this conversation.