I updated to the latest CSV importer version and wanted to use the new file import feature. However, when I import a CSV stating a link to an image file the file got not uploaded and not linked in the created content.
My CSV is like this
title, field_image
"My title", http://www.example.com/example.jpg
I also tried to pre-upload the picture and use /sites/default/files/example.jpg as a path - same effect.
In the log I see the following, possibly related error:
Warning: file_exists() expects parameter 1 to be a valid path, array given in Drupal\csv_importer\Plugin\ImporterBase->add() (line 140 of XXX/modules/contrib/csv_importer/src/Plugin/ImporterBase.php)
Comments
Comment #2
lashabp commentedYou need to provide the full path to your file '/sites/default/..' is not a full path and external files like http://www.example.com/example.jpg won't work
Comment #3
futurmat commentedThanks for the quick answer. I tried
/var/www/html/website-name/web/sites/default/files/example.png, but still no file shows up after the upload via CSV and I see the same error showing in the Log messages.Comment #4
peraltamori commentedcheck Drupal and SO temporary folder permissions
$ settings ['file_temp_path'] = '/ tmp';
Comment #5
lardi commentedI have tried many times for a few days to upload file with full path like this
'/var/www/drupal8/sites/default/files/abc.mp3', but I get this error in report:Comment #6
adao.boscolo commentedHello,
We used a different approach to upload image to content-type with field_image and works:
1. Install and configure IMCE (https://www.drupal.org/project/imce);
2. Upload all images with IMCE inside FCKEditor or content > media > add media > image > open file browser > upload (accept multiple files);
3. Open views > files (Page (/admin/content/files) and click in edit;
4. Click in File ID (fid) and uncheck the field "Exclude from display";
5. The list show all ids from images.
6. Use de Fid id in your image path in CSV file, for example:
title;field_image;body|value;body|format
Text title;10;Body text in html;full_html
Comment #7
pedrotgo commentedHello,
I have this problem too. Is there any solution to this?
I have tried everything you have proposed but I still get the error.
About IMCE I have a lot of contents it would be impossible to reference by id every image and file one by one.
Comment #8
adao.boscolo commentedHello,
Other option to images is the module "Image Media Export Import" (https://www.drupal.org/project/image_export_import).
Uses the pattern:
nid,title,image_file_name,image_alt,image_title
To update de nodes in bulk.
Comment #9
lashabp commentedHello guys, i'll review this issue Tomorrow and let you know, thanks.
Comment #11
lashabp commentedFixed, please try out 1.10 version, thanks.
Comment #12
lashabp commentedComment #14
alberto56 commentedPossibly related to #3170504: On high-availabilities setups with multiple containers, the /tmp directory might differ between calls, make the error message more descriptive