Jump to content

When space or symbol in images name, prestashop 1.6 shows "Error copying image" during import csv


Recommended Posts

Hi,I was using prestashop 1.3.7, today I tried a new site with prestashop 1.6.0.14 .While I got a problem during import csv files.

it shows "Error copying image"  

 

I did everything carefully. I think maybe it's because of the images' name.There's space and symbols in the names.I tested with images name 1.jpg,2.jpg,3.jpg ,and they working well.

 

Could anyone help me to resolve this problem ???Thank you a lot!

post-173821-0-07857000-1427743256_thumb.jpg

Link to comment
Share on other sites

I had this problem too after upgrading to 1.6.0.14

 

This happened because spaces in the URL for the image was decoded to + instead of %20

 

I noticed this additional code in /controllers/admin/AdminImportController.php around lines 1020 that wasn't there before the upgrade:

		$url = urldecode($url);
		$parced_url = parse_url($url);

		if (isset($parced_url['path']))
		{
			$uri = ltrim($parced_url['path'], '/');
			$parts = explode('/', $uri);
			foreach ($parts as &$part)
				$part = urlencode ($part);
			unset($part);
			$parced_url['path'] = '/'.implode('/', $parts);
		}

		if (isset($parced_url['query']))
		{
			$query_parts = array();
			parse_str($parced_url['query'], $query_parts);
			$parced_url['query'] = http_build_query($query_parts);
		}

		if (!function_exists('http_build_url'))
			require_once(_PS_TOOL_DIR_.'http_build_url/http_build_url.php');

		$url = http_build_url('', $parced_url);

Removing it worked for me.

 

DISCLAIMER: This is probably not the right way to solve it and the problem will happen again with the next upgrade. You should probably use some override, or change some config in apache/php/nginx. If you do find the correct way to fix it, please let me know.

Edited by tjtang (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 3 months later...

I had this problem too after upgrading to 1.6.0.14

 

This happened because spaces in the URL for the image was decoded to + instead of %20

 

I noticed this additional code in /controllers/admin/AdminImportController.php around lines 1020 that wasn't there before the upgrade:

		$url = urldecode($url);
		$parced_url = parse_url($url);

		if (isset($parced_url['path']))
		{
			$uri = ltrim($parced_url['path'], '/');
			$parts = explode('/', $uri);
			foreach ($parts as &$part)
				$part = urlencode ($part);
			unset($part);
			$parced_url['path'] = '/'.implode('/', $parts);
		}

		if (isset($parced_url['query']))
		{
			$query_parts = array();
			parse_str($parced_url['query'], $query_parts);
			$parced_url['query'] = http_build_query($query_parts);
		}

		if (!function_exists('http_build_url'))
			require_once(_PS_TOOL_DIR_.'http_build_url/http_build_url.php');

		$url = http_build_url('', $parced_url);

Removing it worked for me.

 

DISCLAIMER: This is probably not the right way to solve it and the problem will happen again with the next upgrade. You should probably use some override, or change some config in apache/php/nginx. If you do find the correct way to fix it, please let me know.

Thank you a lot . This way resolved my problem perfectly. You the best .

Thank you thank you thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...