I have the below url of a image. It's resolution about 1500px width and 300kb. I sent the url to server via ajax and tried to save. But it's saving half of the image. Like corrupted.
Image url:
$url = "https://textronic.online/WEB_API_TDS/v1/img?part=SHSLIM&swatch=F1A0F99B/part=9038004B&swatch=F1A0F99B/part=7FEA98C3&pair=9038004B&swatch=F1A0F99B&pair=9038004B/part=BTBLACK&pair=9038004B&swatch=F1A0F99B&pair=9038004B/part=BHBLACK&pair=9038004B&swatch=F1A0F99B&pair=9038004B/part=EA8BD88C&swatch=F1A0F99B/part=7FEA98C3&pair=EA8BD88C&swatch=F1A0F99B&pair=EA8BD88C/part=BTBLACK&pair=EA8BD88C&swatch=F1A0F99B&pair=EA8BD88C/part=BHBLACK&pair=EA8BD88C&swatch=F1A0F99B&pair=EA8BD88C/part=E339C530&swatch=F1A0F99B/part=7FEA98C3&pair=E339C530&swatch=F1A0F99B&pair=E339C530/part=BTBLACK&pair=E339C530&swatch=F1A0F99B&pair=E339C530/part=BHBLACK&pair=E339C530&swatch=F1A0F99B&pair=E339C530/part=B5CB81BC&swatch=F1A0F99B/part=7FEA98C3&pair=B5CB81BC&swatch=F1A0F99B&pair=B5CB81BC/part=BTBLACK&pair=B5CB81BC&swatch=F1A0F99B&pair=B5CB81BC/part=BHBLACK&pair=B5CB81BC&swatch=F1A0F99B&pair=B5CB81BC/part=REGULARBOTTOM&swatch=F1A0F99B/part=7FEA98C3&swatch=F1A0F99B/part=DIAMOND&swatch=F1A0F99B/part=BOXPLEAT&swatch=F1A0F99B/part=EPNO&swatch=F1A0F99B/part=BHBLACK&swatch=F1A0F99B/part=BTBLACK&swatch=F1A0F99B/view=face";
Method -1
$contents=file_get_contents($url);
$save_path="dimage.jpg";
file_put_contents($save_path,$contents);
Result: image should be red color. but it's white color. the reason is not fully saved.
Method-2
copy($url, 'image2.jpg');
Result: image should be red color. but it's white color. the reason is not fully saved.
Method-3 curl method. This wasn't worked. saved 0kb image.
Method-4
header("content-type: image/jpg");
$qr_image = imagecreatefrompng($url);
$save = getcwd()."image4.jpg";
imagejpeg($qr_image,$save); //save the file to $save path
imagejpeg($qr_image); //display the image
Result is corrupted.
Basically tried the below post methods:PHP - Copy image to my server direct from URL
If anyone have a solution please answer here.
Thank you