11

I am importing products using the built-in CSV import (System - import - products)

All my data is imported fine, but I get an error "Imported resource (image) could not be downloaded from an external resource due to timeout or access permissions in rows: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10"

in my case, I have written the base_image path as http://mywebsite.ca/pub/media/import/img/hose/jpg/Ach7938.jpg

as a test, I removed my folder structure, edited the CSV and tried this and got the same problem, same error http://mywebsite.ca/pub/media/import/Ach7938.jpg

I tried writing file path as so /pub/media/import/img/hose/jpg/Ach7938.jpg but it won't let me past the "check data" validator.

I confirmed the permissions on the folders and files is 775

I am using PHP 5.6, I tried 7 but it broke the whole site in many different ways, so that isn't an option

As a side note, if I run this 20 times in a row, the entire site hangs and import won't work again until I do a full system restore (what's up with that?)

Can I put the images on a different server and link to them that way?

1

17 Answers 17

10

the image path should be something like this in the csv: Ach7938.jpg

M1 would then search for the image file in media/import so I think it would be pub/media/import in M2

You could create a product with an Image and then export the data to get a clue how the value in the csv has to be

6

Not sure if this has anything to do with your issue as this is an internal import but:

In M2 I have images stored in pub/media/import but would get the same error

  1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1, 2

I removed the path name from my CSV file and just have the image path as image.jpg with no slashes and it works great now.

1
  • I think this is specific to your case. Your images are directory in the directory not in a sub directory.
    – tread
    Feb 28, 2017 at 14:26
6

I got the error mentioned as "Imported resource (image) could not be downloaded from an external resource due to timeout or access permissions" when I used the following format of CSV file to import an image in Magento 2.0.0 version(Windows 10).

The format of CSV which I used was as following >>

sku,base_image,errors
WT09-XS-Purple,/pub/media/import/wt09-white_back-test.jpg

and under the File to import section's subsection Images File Directory I used the path as /pub/media/import

I had the image to be imported at pub/media/import location

The problem solved when I used the following CSV format :

"sku","base_image"
"WT09-XS-Purple","wt09-white_back-test.jpg"

and Images File Directory value as pub/media/import enter image description here

The issue on Github: https://github.com/magento/magento2/issues/2666

1
  • As of Magento 2.3.2 the correct image location for import is: <Magento root folder>/var/import/images
    – Isaac
    Nov 29, 2019 at 19:21
5

It seems in 2.3.5 it already adds in the path var/import/images. Move your images into this file then import without adding in the var/import/images path into the image import tool.

2

i am now working on Magento 2.2.6 / 7
and i faced the same error because directory path mechanism of different operating systems.

lets assume if images are in pub/media/import folder than we should mention the path like that :
1. in Windows (mostly for localhost/development purpose)- /pub/media/import
2. in Ubuntu (mostly for production server)- pub/media/import

here the one extra slash is causing the problem.

2

Problem: Image should be inside var folder not the pub folder

Format in your CSV File:

base_image | .. | ..
image_name.png | .. |..

Place all your images < Magento root directory >/var/import/images/

ex: < Magento root directory >/var/import/images/image_name.png

Check file permission of image file and start the import.

1

If you imported with external image url you can see my hotfix.

I found the problem come from the duplicate path for image after download from external url image.

I also created a pull request for it.

1
  • That worked for me. Could not import images from external urls anymore in 2.2.7. Mar 19, 2019 at 18:55
1

Just fixed the same issue by setting the owner of the images in pub/media/import to the web user.

In var/log/exception.log I found the following

[2019-06-05 21:02:06] main.CRITICAL: File 'pub/media/import/xxxx.jpg' was not found or has read restriction. {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): File 'pub/media/import/xxxx.jpg' was not found or has read restriction. at /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog-import-export/Model/Import/Uploader.php:209)"} []

Under a Bitnami install the files were uploaded via FTP as the user 'bitnami' but in this install the webuser is 'daemon'

I ran the following to fix all ownerships on a Bitnami install and now it imports the images. Dont run this if your web user is not daemon.

sudo chown -R daemon:daemon /opt/bitnami/apps/magento/htdocs && sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento-cli``

Although this solution is for a BItnami install it might help find your issue.

1

In magento 2.3.6, it automatically picks image's path. You don't need to mentioned in "Images File Directory".

let me explain in steps:

  1. Make product csv file with 'base_image,small_image,thumbnail_image,additional_images' whatever columns you want to upload
  2. Upload product images to folder <magento_root>/var/import/images
  3. Import csv file from magento admin, keep blank "Images File Directory" field
0

Image path can be or cannot be without / that isn't problem. I've imported with both and it worked. In my case issue was the images given in path wasn't available in folder. I tried it with importing available and not-available image and was getting error in case when that image wasn't available. Path can be any one ,it isn't must to use pub/media/import only.

0

For the import images issue i have fixed the issue from Uploader.php file. change below file path code and success working import images.

File path: magento/vendor/magento/module-catalog-import-export/Model/Import/Uploader.php

Find the below line from line number 201:

$filePath = $this->_directory->getRelativePath($filePath . $fileName);

Replace with:

$filePath = strpos($filePath, $fileName) !== false ? $filePath:$this->_directory->getRelativePath($filePath . $fileName);

For More information Refer github link:

https://github.com/magento/magento2/pull/20761/commits/8612789375b0c173f0ba852c587882af6ff8bc7f

4
  • but in 2.3.2 the file code does not matches Jul 29, 2020 at 8:53
  • 2.3.3 version not have this code of line Oct 21, 2020 at 5:12
  • It was in native magento 2.3.1 You can find in native version. Oct 21, 2020 at 5:33
  • I have solved this issue without editing any code and imported around 1,000 products, always working fine magento.stackexchange.com/a/325213/82482 Dec 3, 2020 at 4:32
0

I just ran into this issue myself, and the fix had nothing to do with format of my csv or the file location of the images.

What was causing it for me was the permissions on the pub/media/import folder. It seems the images are placed here when being downloaded from an external source. When the system could not create the files here it threw back the mentioned issue.

To fix it all I had to do was run the following command to fix it (from the pub/media folder):

sudo chmod 777 import

Once I did this my products imported without error.

0

Following is the file to overite, modification in vendor file is not recommended.

vendor\magento\module-catalog-import-export\Model\Import\Uploader.php

Jump to line no 249 i.e here "if ($this->getTmpDir())" and replace it with ($this->getTmpDir() && strpos($filePath, $this->downloadDir) !== 0)

Copy all images to your root directory under "images" folder

Now open CSV and assign image with full URL such as www.domain.com/images/test.jpg or http://127.0.0.1/mage233/images/test.jpg

Now go back to Admin and upload this CSV without defining the path to "Images File Directory"

This time it should work.

0

I had the same problem with importing images from the backend.

Upload your images to var/tmp

It worked for me.

0

There are many thing involve but you must notice some important things are as

  • image name same as in import list
  • name image have special character
  • have place image in media image folder
  • check name of image in media folder as well as in import list are same
0

I use Magento 2.4 and have the same problem. Finally, I found the solution below

Method 1: For importing an image from local

  1. Don't use a special character or foreign character in the image filename.
  2. Give proper Permissions on the pub/media/import folder. I give 777 for pub/media folder.

Method 2: For importing an image from an external site like http://example.com/image/i/m/image.jpg

  1. the URL of image length can't more than 90 characters. (If your image URL more than 90 chars, please go to https://stackoverflow.com/a/62790372 for modifying the condition criteria on Uploader.php.)
  2. Give proper Permissions on the pub/media/import folder. I give 777 for pub/media folder.
0

I was using csv that M2 generated in export process.

My file names had capital letters but M2 had imported those files with small letters and I couldn't use them in later import for different product because of case sensitiveness. You have to watch out for file names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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