1

I'm using CakePHP 3.2 and proffer plugin to upload images and generate thumbnails.

Proffer plugin is working fine with images selected from input field type file.

Now, I have a separate directory with images say products on the server and and image in it say my_image.jpg

I have to pass this image via proffer upload same as using the form. Only difference is instead of selecting an image from form, I'm taking it from a directory.

my image path is like

$full_image_path = '/products/my_image.jpg';

and saving it like

$productImage = $this->ProductImages->patchEntity($productImage, [
  'image' => $full_image_path,
  'product_id' => 1
]);
$this->ProductImages->save($productImage);

But this is giving error as

Illegal string offset 'tmp_name'

How can i get and pass tmp_name of image ?

Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
  • You set incorrect path to file. – Salines Sep 03 '16 at 09:43
  • 1
    the path of file is outside cakephp files. I have a separate subdomain `media` and path to file where images are. path from root is `/home/user/media/files/products` and application is in `/home/user/site`. Image uploading is working file. But my question is I don't want to get image from a form instead get it by url. – Anuj TBE Sep 03 '16 at 09:53
  • 1
    So, the user is entering a URL and you want to retrieve that image? That's not an upload, and you won't be given data that looks anything like it does in the case of uploads. You'll want to use something like the cURL library to fetch the image and then save it wherever you want it. – Greg Schmidt Sep 04 '16 at 02:48
  • thanks @Greg Schmidt. – Anuj TBE Sep 04 '16 at 02:50
  • I suppose the question is: Is there any way to user Proffer with `file_get_contents()` or by any means from a URL ? – Tomas Gonzalez Aug 25 '18 at 03:10

0 Answers0