I have a script on my server which dynamically generates an image. A user could refer to that image in the browser from /image/index/generated_image_name.jpg where "generated_image_name" is sent as an argument to a function which outputs the resulting jpg.

Now, from another page I need to use cURL to send that image, and other data with post. How can I achieve this? I believe the problem here is that I cannot simply run realpath() on a file that's not a real file.. so I essentially need to output the image and store it into memory to use curl.

Alternatively, is there a way to send a cURL request directly from a URL?