Jump to content

Download image to my server with php


sammeras

Recommended Posts

Hello,

I am new at php.

I am trynig to download image to my server (OR to my local computer).

The images located at:  http://pms.panet.co.il/online/images/music_new/222.jpg[/b]]http://pms.panet.co.il/online/images/music_new/222.jpg

How can download it with php code?

 

 

Best regards,

SAM.

Link to comment
https://forums.phpfreaks.com/topic/107046-download-image-to-my-server-with-php/
Share on other sites

I've done this with zip files but it might be slightly different with images but you can give it a shot.

 

<?php

  $url = "URL_TO_IMAGE";
  $ext = substr(strrchr($url, '.'), 1);
  $imgData = file_get_contents($url);
  
  $myFile = "image_name.".$ext;
  $fh = fopen($myFile, 'w') or die("can't open file");
  fwrite($fh, $imgData);
  fclose($fh);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.