简体   繁体   English

php.ini max_upload_file大小恢复为默认的2M

[英]php.ini max_upload_file size falling back to default 2M

I have to upload 5.7MB database in drupal-7 using module "backup and migrate". 我必须使用模块“备份和迁移”在drupal-7中上载5.7MB数据库。 But, when I upload the file it throws out following error: 但是,当我上传文件时,它抛出以下错误:

The file email839805758.zip could not be saved, because it exceeds 2 MB, the maximum allowed size for uploads.

I have changed post_max_size = 20M and u pload_max_filesize = 40M in php.ini file and created user.ini in /etc/php/5.6/apache2/conf.d/user.ini. 我已经更改了php.ini文件中的pload_max_filesize = 40M post_max_size = 20M和u pload_max_filesize = 40M并在/etc/php/5.6/apache2/conf.d/user.ini中创建了user.ini and pasted post_max_size and upload_max_filesize greater than 2M. 并粘贴大于2M的post_max_size和upload_max_filesize I have checked phpinfo(). 我检查了phpinfo()。 It just gives the default value to 2M. 它只是将默认值设置为2M。 Does anybody have any solution to such kind of scenerio in drupal 7? 在drupal 7中,有人对这种场景有任何解决方案吗?

I have found some additional stuff in drupal backup_migrate.module file which might be the barrier. 我在drupal backup_migrate.module文件中发现了一些其他东西,可能是障碍。 Help me crack this function. 帮我破解这个功能。

  /**
  * A custom version of format size which treats 1GB as 1000 MB rather than 1024 MB
  * This is a more standard and expected version for storage (as opposed to memory).
  */
  function backup_migrate_format_size($size, $langcode = LANGUAGE_NONE)    {
  $precision = 2;
  $multiply = pow(10, $precision);

  if ($size == 0) {
  return t('0 bytes', array(), array('langcode' => $langcode));
   }
  if ($size < 1024) {
  return format_plural($size, '1 byte', '@count bytes', array(),   array('langcode' => $langcode));
  }
  else {
  $size = ceil($size * $multiply / 1024);
  $string = '@size KB';
  if ($size >= (1024 * $multiply)) {
  $size = ceil($size / 1024);
  $string = '@size MB';
  }
  if ($size >= 1000 * $multiply) {
  $size = ceil($size / 1000);
  $string = '@size GB';
  }
  if ($size >= 1000 * $multiply) {
  $size = ceil($size / 1000);
  $string = '@size TB';
  }
   return t($string, array('@size' => round($size/$multiply, $precision)), array('langcode' => $langcode));
  }

  }

Put in phpinfo() in your script and see which php.ini file you are using. 在脚本中放入phpinfo(),然后查看所使用的php.ini文件。 Go into that file and change those values. 进入该文件并更改这些值。 Please keep in mind the daemon has to be restarted (php-fpm or apache) in order for the changes to be activated. 请记住,必须重新启动守护程序(php-fpm或apache)才能激活更改。

If you can not do that for some reason, you can always use the ini_set() function locally while this is highly discouraged! 如果由于某种原因不能执行此操作,强烈建议您在本地使用ini_set()函数!

Check with phpinfo() what php config file was used. 使用phpinfo()检查使用了什么php配置文件。 To me it looks like you edited wrong php.ini. 对我来说,您似乎编辑了错误的php.ini。 Also, don't forget to restart your web server (Apache?). 另外,不要忘记重新启动Web服务器(Apache?)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM