3

I'm encountering a tricky problem with my custom file widget (which extends the core file widget). It chunks files so that I don't have to raise upload_max_filesize and post_max_size in php.ini, and puts them together. The problem is, even though the files now exist remotely (and have also been saved as file entities in Drupal) it refuses to save them into the field, because even though the file field's settings are set to 500 MB, php.ini's uploads are maxed at 20 MB.

The problem is in FileItem.php:

public function getUploadValidators() {
  $validators = array();
  $settings = $this->getSettings();

  // Cap the upload size according to the PHP limit.
  $max_filesize = Bytes::toInt(file_upload_max_size());
  if (!empty($settings['max_filesize'])) {
    $max_filesize = min($max_filesize, Bytes::toInt($settings['max_filesize']));
  }

  // There is always a file size limit due to the PHP server limit.
  $validators['file_validate_size'] = array($max_filesize);

  // Add the extension check if necessary.
  if (!empty($settings['file_extensions'])) {
    $validators['file_validate_extensions'] = array($settings['file_extensions']);
  }

  return $validators;
}

Which calls file_validate_size in file.module. I've already tried using ini_set() to change the file size ini values, but that doesn't seem to work.

So, to recap:

Drupal has the file

My widget tells it to save the file by its fileID for the file field

Drupal tells me it won't save the file that it already has because of php file upload limits


Can anyone think of something I can do to get around this without modifying core?

0

Just a guess, but this may have something to do with max_file_uploads in php.ini. Perhaps chunking it counts as multiple files?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.