6

I have problem!

I can get image and resize it by imagecopyresampled().

But when I try to use ftp_put(): expects parameter 3 to be a valid path.

I try to use:

ob_start();
imagejpeg($resource, NULL);
$resource = ob_get_contents();

It does not help. I don't need to save the image to a local machine.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Philipp Klemeshov
  • 383
  • 1
  • 5
  • 14

1 Answers1

2

Use an FTP protocol wrapper, like:

imagejpeg($resource, "ftp://user:password@example.com/dir/file.jpg");

A more generic "upload in-memory contents to FTP" would be:

ob_start();
imagejpeg($resource, NULL);
$contents = ob_get_contents();
file_put_contents("ftp://user:password@example.com/dir/file.jpg", $contents);

See also Transfer in-memory data to FTP server without using intermediate file.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992