Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get picture from URL -> resize without saving -> upload to FTP?

Tags:

php

ftp

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.

like image 524
Philipp Klemeshov Avatar asked May 23 '15 06:05

Philipp Klemeshov


1 Answers

Use an FTP protocol wrapper, like:

imagejpeg($resource, "ftp://user:[email protected]/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:[email protected]/dir/file.jpg", $contents);

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

like image 146
Martin Prikryl Avatar answered Oct 10 '22 15:10

Martin Prikryl