After finishing the upload and saving the node, the file still is showing in the system temporary directory.

I would expect the file to be listed in the files directory and use the path provided on the file field settings page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shanefjordan created an issue. See original summary.

veronicaSeveryn’s picture

To make it work together with Plupload, I am linking to the issue which contains description/instructions (https://www.drupal.org/node/2245927#comment-11259977).

There're 2 patches involved to make it work the way I had it done.

veronicaSeveryn’s picture

Status: Active » Needs review

Marking for review

david_garcia’s picture

Status: Needs review » Needs work

@veronicaSeveryn Thanks for the patch!

I can't review and commit a feature that depends on an uncommited feature from another module, so I'm marking this as needs work ether until #2245927: Create helper function that will save uploaded files to file_managed table gets in or a different approach is proposed.

Yet I am not sure this is the right direction. The Plupload form element module provides that... just a form element, so it has no knowledge of widgets or file configurations.

I'm not sure if it is "our duty" to move this away from the temp folder.... may taking a look at the original value function from the parent classes:

 public static function value($element, $input = FALSE, FormStateInterface $form_state) {
    if ($input) {
      // Checkboxes lose their value when empty.
      // If the display field is present make sure its unchecked value is saved.
      if (empty($input['display'])) {
        $input['display'] = $element['#display_field'] ? 0 : 1;
      }
    }

    // We depend on the managed file element to handle uploads.
    $return = ManagedFile::valueCallback($element, $input, $form_state);

    // Ensure that all the required properties are returned even if empty.
    $return += array(
      'fids' => array(),
      'display' => 1,
      'description' => '',
    );

    return $return;
  }
Chipie’s picture

@veronicaSeveryn: Thanks. Works for me.

steveoriol’s picture

@veronicaSeveryn: Thanks. Works for me too with the following:

NOTE:
In fact, this works only for the fileld type "file" but not for the fileld type "image" ...

khiminrm’s picture

Hi!
Solution doesn't work in 8.4.2. Any suggestions? Thanks!

khiminrm’s picture

I was able to upload file after changing public folder permission to 777 recursively.
But I've noticed that filename is not appeared near 'Remove' button and I upload new file, after removing uploaded one. Error occurs:
The website encountered an unexpected error. Please try again later.

Error: Call to a member function getValue() on null in Drupal\file\Plugin\Validation\Constraint\FileValidationConstraintValidator->validate() (line 18 of core/modules/file/src/Plugin/Validation/Constraint/FileValidationConstraintValidator.php).
Drupal\file\Plugin\Validation\Constraint\FileValidationConstraintValidator->validate(Object, Object) (Line: 185)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Object, '0000000059c86461000000000e57b7be', Array) (Line: 140)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 147)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 147)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 99)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, NULL, NULL) (Line: 90)
Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object) (Line: 135)
Drupal\Core\TypedData\TypedData->validate() (Line: 411)
Drupal\Core\Entity\ContentEntityBase->validate() (Line: 272)
Drupal\media_entity\Entity\Media->validate() (Line: 180)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 274)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'media_release_edit_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('media_release_edit_form', Array, Object) (Line: 571)
Drupal\Core\Form\FormBuilder->processForm('media_release_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('media_release_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 613)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
khiminrm’s picture

Without any changes in code widget stopped working. After uploading file there is only Remove button without file's name and error after saving form as in #8

khiminrm’s picture

Errors in #8 and #9 have disappeared after flushing site's and browser's cache.
Still one bug: file is not removed from folder when it's removed in admin page from media entity or when whole media entity is removed. Cron also doesn't remove such file. How it can be fixed?

khiminrm’s picture

I've found answer for question in #10 about deleting files. It's related to https://www.drupal.org/node/2891902.

khiminrm’s picture

Patch from #2 works for me with patch from https://www.drupal.org/project/plupload/issues/2245927#comment-11560277. Thanks!!!

Alex Zhulin’s picture

Using:
- Drupal 8.5.3;
- Plupload library 2.3.1;
- plupload 1.x-dev with applied patch from https://www.drupal.org/project/plupload/issues/2245927#comment-11560277 (#7);
- plupload_widget 1.0 with applied patch from #2.

Some file uploads fail because the regular expression parsing element ID does not consider the underscores in the hash appended to the ID after AJAX.
Also extra records are created in the file_managed table for the same file with "temporary://..." uri.

Created a patch based on #2 to fix these issues.
Depends on a patch from https://www.drupal.org/project/plupload/issues/2245927#comment-12596975 (#13).

plato1123’s picture

Wait, this has been broken for 2 years? Can't we get these patches rolled into a release, even if it's just a dev release?

budalokko’s picture

Title: File Upload remains as Temporary file » File Upload remains in Temporary files directory
Status: Needs work » Needs review
FileSize
1.47 KB

Changed issue name to clarify file status is permanent. The problem is it is stored in temporary folder.

Attached is a very small patch that I think solves the problem but I have the feeling I'm missing something because its tiny compared to previous patches and does not involve changes in Plupload Module.

It seems to be working fine for me on:

- Drupal Core 8.5.5
- PlUpload dev - at 20/7/2018 (30f4c1fa42ae2f076d31289433cdb9b35ed72f16)
- PlUpload library 2.1.9

Yaazkal’s picture

#15 seems to do the trick, thanks.

WorldFallz’s picture

#15 seems to be working well for me so far also. Combined with #2662696-16: multiple values setting for a field are not taken into account when saving, only first file makes this the perfect module for bulk uploads.

masande’s picture

I've combined #15 with patch in #2662696 and am getting each image added via plupload uploaded twice. I only applied this patch to FileWidget.php. Do I need to also change ImageWidget.php to match FileWidget.php? Anyway someone could provide a patch combining the patches fixing both issues? Thanks!

budalokko’s picture

Attached patch is the same as #15 regarding file widget and fixes image widget too.

@masande: The duplicate files issue is due to "file_copy" in #2662696-12: multiple values setting for a field are not taken into account when saving, only first file. It should be a file_move. I have a combination of patches which I think is working fine. I won't send it here because it combines at least 4 issues from this issue queue and I think we should face each problem separately but feel free to PM me and I will send it. For the multiple files problem its based in #2986932: Add multiple file support.

AstonVictor’s picture

AstonVictor’s picture

cweagans’s picture

jrglasgow’s picture

I have added some code from this ticket to my branch for #3124700: Deprecated Code Report to make it compatible with D9

budalokko’s picture

Status: Needs review » Fixed

Closing as this is solved in 2.0.x-dev branch now, after committing #3124700: Deprecated Code Report.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.