Upload image from URL to FTP server using PHP

Posted by user1807556 on Stack Overflow See other posts from Stack Overflow or by user1807556
Published on 2012-11-07T22:57:02Z Indexed on 2012/11/07 22:59 UTC
Read the original article Hit count: 171

Filed under:
|
|

I want to upload a picture from another site to my FTP server using PHP.

Example:

File to upload("http://page.mi.fu-berlin.de/krudolph/stuff/stackoverflow.png")

FTP-path("pictures/")

This is what I've already tried:

1

$image = file_get_contents("http://img.youtube.com/vi/Rz8KW4Tveps/1.jpg");
file_put_contents("imgfolder/imgID.jpg", $image);

2

copy('http://img.youtube.com/vi/Rz8KW4Tveps/1.jpg', 'imgfolder/imgID.jpg');

3

    <?php
set_time_limit (24 * 60 * 60);

if (!isset($_POST['submit'])) die();

$file = fopen ($url, "rb");
if ($file) {
  $newf = fopen ($newfname, "wb");

  if ($newf)
  while(!feof($file)) {
    fwrite($newf, fread($file, 1024 * 2000 ), 1024 * 2000 );
  }
}

if ($file) {
  fclose($file);
}

if ($newf) {
  fclose($newf);
}

?>

4

http://www.teckdevil.com/php-server-to-server-transfer-script-to-remotely-transfer-files/

5

(kinda the same as first linked) Download files directly to my server

#

I don't get any errors when I'm running the scripts and I have chmod the directory to 777.

© Stack Overflow or respective owner

Related posts about php

Related posts about upload