简体   繁体   中英

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". 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. and pasted post_max_size and upload_max_filesize greater than 2M. I have checked phpinfo(). It just gives the default value to 2M. Does anybody have any solution to such kind of scenerio in drupal 7?

I have found some additional stuff in drupal backup_migrate.module file which might be the barrier. 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. 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.

If you can not do that for some reason, you can always use the ini_set() function locally while this is highly discouraged!

Check with phpinfo() what php config file was used. To me it looks like you edited wrong php.ini. Also, don't forget to restart your web server (Apache?).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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