Copy Image From Remote Server To Local


/ Published in: PHP
Save to your folder(s)

PHP function to save an image from a remote source then download it to the local server that the script is on.


Copy this code and paste it in your HTML
  1. <?php
  2. function save_image($inPath,$outPath)
  3. { //Download images from remote server
  4. $in= fopen($inPath, "rb");
  5. $out= fopen($outPath, "wb");
  6. while ($chunk = fread($in,8192))
  7. {
  8. fwrite($out, $chunk, 8192);
  9. }
  10. fclose($in);
  11. fclose($out);
  12. }
  13. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.