File uploads stop with some files

Created on 27 April 2023, over 1 year ago
Updated 20 November 2023, about 1 year ago

On some workstations - I personally couldn't yet reproduce the problem - upon uploading large files - e.g. above 200 MB - the upload stops and an exception is thrown similar to the one I report below (I used ROOT_DIRECTORY and HOSTNAME in place of the original text for privacy).

Uncaught
Object { message: "\nSi รจ verificato un errore HTTP in AJAX.\nCodice HTTP di risposta: 200\nDi seguito le informazioni di debug.\nPercorso: /node/add/video?element_parents=field_file_video/widget&ajax_form=1\nStatusText: OK\nResponseText: \nFatal error:  Out of memory (allocated 10485760) (tried to allocate 224396424 bytes) in /ROOT_DIRECTORY/web/core/lib/Drupal/Core/File/FileSystem.php on line 76", name: "AjaxError", stack: "@https://HOSTNAME/core/misc/ajax.js?v=10.0.8:184:32\n@https://HOSTNAME/core/misc/ajax.js?v=10.0.8:1798:3\n" }

I left the original Italian parts, but the meaning should be obvious.

"video" is a content type with a single file field that allows to upload one or more files.

I'm stuck, since I cannot even interpret that out of memory matter. Both the PCs where the problem occurs and where the problem does not have quite enough RAM available.

What can I do?

Thanks in advance!

Andrea

--- UPDATE ---
I finally got the error with a couple of files slightly above 200 MB and slightly below 400 MB, but very curiously I repeatedly uploaded a file above 400 MB! Then I tried with dummy files made with dd and found uploads are however OK with files slightly below 200 MB - I cannot yet tell what the edge is...
However, I eventually figured out I can see the error directly in the response to the POST request. I report an example below, with ROOT_DIRECTORY in place of the actual path.

: Out of memory (allocated 14680064) (tried to allocate 380428904 bytes) in on line

๐Ÿ’ฌ Support request
Status

Closed: outdated

Version

10.0 โœจ

Component
File systemย  โ†’

Last updated about 11 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly AppLEaDaY

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @AppLEaDaY
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    The error message suggests the memory_limit setting in php.ini is 256Mb. You should increase this to a more appropriate setting for your server and the size of files you wish to upload.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly AppLEaDaY

    @longwave, thanks... though with a phpinfo() I see the value for memory_limit is 1024M. Besides the problem is not strictly related to the size of the file. I could successfully upload a file larger than 400 MB and I couldn't with smaller files. In general the upload goes however OK with files slightly below 200 MB in size.

  • Status changed to Postponed: needs info over 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Have you tried setting a higher memory_limit? "Out of memory" is just that, and there is nothing that Drupal can do about it; this is a PHP configuration issue.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly AppLEaDaY

    Premise: I notice when I comment the priority of the issue is reverted back to "critical", but that's not me, that's something automatic.

    @longwave, not phpinfo says memory_limit is 2048M, twice the previous value, but the problem is still there.

    : Out of memory (allocated 14680064) (tried to allocate 224396424 bytes) in on line

    Something about the file follows - coming from "ls -l").

    -rw-rw-r-- 1 andrea andrea 224396398 mar 25 00:24 video.mp4

    Did you see perhaps anything strange in the numbers?

    Please notice the update I made in my post. Mysteriously - for now - I could repeatedly upload one particular file that is more than 400 MB in size. This is puzzling, isn't it?

    Thanks in advance!

    Andrea

    Thanks in advance!

    Andrea

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly AppLEaDaY

    --- UPDATE ---
    I've just set up a local instance of the website on the PC I'm using.

    In php.ini I didn't change the following setting I found there.

    memory_limit = 128M

    Result: I have no problems in uploading big files.

    So where does that "out of memory" come from on the shared hosting environment?

    Thanks in advance!

    Andrea

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly AppLEaDaY

    @cilefen, as far as I could see it's a matter of upload_max_filesize, post_max_size and memory_limit, but shouldn't I trust what a phpinfo displays for their values? I'm pretty sure the values I've set for those parameters are enough for the uploads I've in mind.

    The "out of memory" occurs at line 76 of core/lib/Drupal/Core/File/FileSystem.php.

    Here's what is at line 76...

    $result = @move_uploaded_file($filename, $uri);

    I took my time to copy from the web and paste some html and some php code to upload a file with a POST request.
    Curiously enough with that code I could successfully upload a file I could not upload with the Drupal form.
    And that code contains the function move_uploaded_file.

    This is puzzling to me. I don't mean to argue about any responsibility of Drupal. I kept on writing because I hope to get some idea from knowledgeable people.

    Thanks!

  • Status changed to Closed: outdated about 1 year ago
  • I am closing this issue due to inactivity. Reopen it as necessary.

Production build 0.71.5 2024