I got this error when I'm trying to migrate my image from Prestashop to Opencart using PHP. Can anyone here helps me? How can I fix the error?
It seems like the array have a problem. Any suggestions thanks.
<?php
class ControllerToolMigrate extends Controller {
public function index() {
$this->load->model('catalog/product');
$filter_data = array(
'start'=> 0,
'limit'=> 5
);
$results = $this->model_catalog_product->getProductsImage($filter_data);
foreach ($results as $result) {
foreach($result as $sub_product){
$str = $sub_product['id_image'];
$arr1 = str_split($str);
$arr2 = str_split($str,2);
print_r($arr1);
print_r($arr2);
$link = '';
echo $str;
foreach($arr1 as $id){
$com = array($id);
$link .= $com[0] .'/';
}
$link .= $str;
echo var_dump ($link);
echo $link;
$newLink = 'http://localhost/onlinestore/img/p/'.$link.'-large_default.jpg';
//Get the file
$content = file_get_contents($newLink);
//Store in the filesystem.
$fp = fopen("../upload/image/catalog/demo/p/".$str."-large_default.jpg", "w");
fwrite($fp, $content);
fclose($fp);
}
}
//Get the file
/*$content = file_get_contents("http://www.tImOLI12t.my/onlinestore/img/p/9/9-large_default.jpg");
//Store in the filesystem.
$fp = fopen("../upload/image/catalog/demo/p/large_default.jpg", "w");
fwrite($fp, $content);
fclose($fp);*/
}
}