0

We are trying to migrate our website from smaller provider to Azure, everything went smooth except that we are unable to download files that have more then 2MB when trying to do that we are getting error 400.

Already tried multiple solution for example: https://azureossd.github.io/2020/09/15/unable-to-download-static-content-php-on-azure-app-service-linux/index.html playing with php.ini, testing in any other Azure Linux container is giving the same output, there are no logs about that on Azure.

Here's portion of code that we are using for testing:

$file = "test.exe";
$quoted = sprintf('"%s"', addcslashes(basename($file), '"\\'));
$size   = filesize($file);

header('Content-Description: File Transfer');
header('Content-Type: application/*');
header('Content-Disposition: attachment; filename=' . $quoted); 
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $size);    

readfile($file);

I compared php and apache settings from the old server and they are practically the same, what am I missing here?

Marcin
  • 11
  • 1

1 Answers1

0
  1. Create a new ini file: /home/site/ini/my.ini with the following contents:
upload_max_filesize = 150M  
post_max_size = 100M
  1. Use PHP_INI_SCAN_DIR AppSetting to let the system use your additional ini config, with below value : /usr/local/etc/php/conf.d:/home/site/ini
Gaurav Kumar
  • 136
  • 8