@all I solved it though it's a many code
if (!empty($row[12])) {
$download_image = $row[12];
$original_name = basename($download_image);
$original_extension = substr($original_name, strrpos($original_name, '.')); // ".jpg"
$types = array(
'image/avif' => '.avif',
'image/avif' => '.avifs',
'image/bmp' => '.bmp',
'image/cgm' => '.cgm',
'image/g3fax' => '.g3',
'image/heic' => '.heif',
'image/heic' => '.heic',
'image/ief' => '.ief',
'image/jpeg' => '.jpe',
'image/jpeg' => '.jpeg',
'image/jpeg' => '.jpg',
'image/jpeg' => '.pjpg',
'image/jpeg' => '.jfif',
'image/jpeg' => '.jfif-tbnl',
'image/jpeg' => '.jif',
'image/pjpeg' => '.jpe',
'image/pjpeg' => '.jpeg',
'image/pjpeg' => '.jpg',
'image/pjpeg' => '.pjpg',
'image/pjpeg' => '.jfi',
'image/pjpeg' => '.jfif',
'image/pjpeg' => '.jfif-tbnl',
'image/pjpeg' => '.jif', //end
'image/png' => '.png',
'image/prs.btif' => '.btif',
'image/svg+xml' => '.svg',
'image/svg+xml' => '.svgz',
'image/tiff' => '.tif',
'image/tiff' => '.tiff',
'image/vnd.adobe.photoshop' => '.psd',
'image/vnd.djvu' => '.djv',
'image/vnd.djvu' => '.djvu',
'image/vnd.dwg' => '.dwg',
'image/vnd.dxf' => '.dxf',
'image/vnd.fastbidsheet' => '.fbs',
'image/vnd.fpx' => '.fpx',
'image/vnd.fst' => '.fst',
'image/vnd.fujixerox.edmics-mmr' => '.mmr',
'image/vnd.fujixerox.edmics-rlc' => '.rlc',
'image/vnd.ms-modi' => '.mdi',
'image/vnd.net-fpx' => '.npx',
'image/vnd.wap.wbmp' => '.wbmp',
'iimage/vnd.xiff' => '.xif',
'image/webp' => '.webp',
'image/x-adobe-dng' => '.dng',
'image/x-canon-cr2' => '.cr2',
'image/x-canon-crw' => '.crw',
'image/x-cmu-raster' => '.ras',
'image/x-cmx' => '.cmx',
'image/x-epson-erf' => '.erf',
'image/x-freehand' => '.fh',
'image/x-freehand' => '.fh4',
'image/x-freehand' => '.fh5',
'image/x-freehand' => '.fh7',
'image/x-freehand' => '.fhc',
'image/x-fuji-raf' => '.raf',
'image/x-icon' => '.ico',
'image/x-kodak-dcr' => '.dcr',
'image/x-kodak-k25' => '.k25',
'image/x-kodak-kdc' => '.kdc',
'imimage/x-minolta-mrw' => '.mrw',
'image/x-nikon-nef' => '.nef',
'image/x-olympus-orf' => '.orf',
'image/x-panasonic-raw' => '.raw',
'image/x-panasonic-raw' => '.rw2',
'image/x-panasonic-raw' => '.rwl',
'iimage/x-pcx' => '.pcx',
'image/x-pentax-pef' => '.pef',
'image/x-pentax-pef' => '.ptx',
'image/x-pict' => '.pct',
'image/x-pict' => '.pic',
'image/x-portable-anymap' => '.pnm',
'image/x-portable-bitmap' => '.pbm',
'image/x-portable-graymap' => '.pgm',
'image/x-portable-pixmap' => '.ppm',
'image/x-rgb' => '.rgb',
'mage/x-sigma-x3f' => '.x3f',
'image/x-sony-arw' => '.arw',
'image/x-sony-sr2' => '.sr2',
'image/x-sony-srf' => '.srf',
'image/x-xbitmap' => '.xbm',
'image/x-xpixmap' => '.xpm',
'image/x-xwindowdump' => '.xwd',
);
$img = file_get_contents($download_image);
$stored_name = 'stock-image-' . time(). $original_extension;
if ($img) {
file_put_contents($stored_name, $img);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $stored_name);
if (isset($types[$mimetype])) {
if ($types[$mimetype] != $original_extension) {
rename($stored_name, 'stock-image-' . $types[$mimetype]);
}
}
finfo_close($finfo);
}
Storage::put('public/stocks/' . $stored_name, $img);
$row[12] = $stored_name;
}