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

futurmat created an issue. See original summary.

lashabp’s picture

You 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

futurmat’s picture

Thanks 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.

peraltamori’s picture

check Drupal and SO temporary folder permissions
$ settings ['file_temp_path'] = '/ tmp';

lardi’s picture

I 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:

Recoverable fatal error: Object of class Drupal\Core\Config\ImmutableConfig could not be converted to string in Drupal\csv_importer\Plugin\ImporterBase->add() (line 153 of /var/www/drupal8/modules/contrib/csv_importer/src/Plugin/ImporterBase.php)
adao.boscolo’s picture

Hello,

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

pedrotgo’s picture

Hello,
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.

adao.boscolo’s picture

Hello,

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.

lashabp’s picture

Hello guys, i'll review this issue Tomorrow and let you know, thanks.

  • lashabp committed ed55527 on 8.x-1.x
    Issue #3129972: Error file upload
    
lashabp’s picture

Fixed, please try out 1.10 version, thanks.

lashabp’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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