The goal:
I have a URL of an image. I would like to get the image file and to upload it to $_FILES as if the image was uploaded by a client.
The reason:
I need this because I have a form in which users can either upload an image file in a input type="file" field OR enter an image URL in a input type="text" field and later, when I validate the form, I want the validation function to access the file using $_FILES regardless the method the user chose to supply the image (either by uploading a file or by entering a file URL.)
The problem:
I found this answer on using file_put_contents() and file_get_contents() but I don't understand if I can use it to change $_FILES and if yes then how.
EDIT:
After reading David's comment, I understood my mistake. What I actually need is a way to download a file from a URL using file_get_contents() and file_put_contents() to the same temporary location on the server that uploaded files are downloaded to. By that I would be able to handle files the same way regardless of how they got there (URL or file upload).