[Solved] How to import images in a bulk import function? [closed]


You can use as bellow script for CSV

$row = 1;
$counter = 0;
$urls = array();

$desdir = "Destination_DIR_URL";
//Ex:  250x250/ for current directory, create the directory with named 250x250
if (($handle = fopen("targetfile.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$counter++;

$row++;

if($counter > 1 && is_array($data) && sizeof($data) > 3){

    $tmppos = strpos($data[3]."","Source_Folder_Url");

    if($tmppos === 0){
        $file = $data[3];
        $farry = explode("https://stackoverflow.com/",$file);
        $filename = end($farry);
        //echo $filename."<br>";
        $urls[$counter] = $file;

        //$current = file_get_contents($file);
        if(!file_exists($desdir.$filename)){
            copy($file,$desdir.$filename);
        }
    }

  }

}
 fclose($handle);
}

solved How to import images in a bulk import function? [closed]