Alexandre Khoury
Alexandre Khoury

Reputation: 4012

Manipulate image without saving it

I want to do things on an image uploaded by the user.

Until now, what I do is:

  1. move_uploaded_file
  2. imagecreatefrompng

How can I manipulate it without saving it?

Upvotes: 1

Views: 155

Answers (1)

Bojangles
Bojangles

Reputation: 101473

When the file is uploaded, it has to be stored somewhere in the server's /tmp/ folder. Simply load your image from there using $_FILES['name']['tmp_name'].

For example:

$image = imagecreatefrompng($_FILES['blarg']['tmp_name']);

Will load the uploaded file (called blarg) from it's temporary storage place under something like /tmp/php-12bja. You don't need to call move_uploaded_file(), and the image doesn't need to be saved to disk.

Upvotes: 1

Related Questions