Laravel files throwing error when file is too large (Nginx, Azure App Service)

Viewed 27

I have recently upgraded to PHP 8 on Azure which replaced Apache2 with NGINX. I am now experiencing a lot of issues.

I am trying to write to a path inside of Laravel based on the files contents:

\Illuminate\Support\Facades\File::append($path, request()->file('file')->get());

I see this error on larger files:

Illuminate\Contracts\Filesystem\FileNotFoundException File does not exist at path.

If I dd the request()->file('file') I see the following:

Illuminate\Http\UploadedFile {#4194
  -test: false
  -originalName: "blob"
  -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
}

The error is thrown on the ->get(). This tells me that the file is not saving correctly to the /tmp directory PHP is using. To this effect, I altered my nginx configuration to contain the following:

client_max_body_size 100M;

I restarted nginx so the changes would take effect but I still recieve this error.

Is there something I need in my php.ini or configure inside of Azure?

If I upload a file of 45368 bytes it works fine, if I upload one with 278712 bytes it works fine, if I upload one with 5712115 I get the error.

Any help appreciated.

1 Answers

After some further research around the comments raised on this post, I found the following documentation.

When running the said php --ini command, you'll see /usr/local/etc/php/conf.d is listed in there. Changing your PHP_INI_SCAN_DIR to another directoy looses all this configuration/drivers so you'll need to instead use an additonal : to specify a new directory. I created one in my repo to persist this across all the deployment servers.

My directory is php which contains custom.ini and then my PHP_INI_SCAN_DIR is configured to:

/usr/local/etc/php/conf.d:/home/site/wwwroot/php
Related