If someone were to upload an image via a form:
<form method="post" accept="image/*" enctype="multipart/form-data">
<input size="28" name="image_upload" type="file">
<input type="submit" value="Submit">
</form>
In PHP you can get the uploaded image_upload
via $_FILES
variable:
if(isset($_FILES['image_upload']))
var_dump($_FILES['image_upload'])
And you can proceed to do things with it, such as show the tmp_name
and can move_uploaded_file
.
How do I allow someone to upload an image if they were to use CURL, like this, but without the form?
$POST_DATA = array(
'ImageData' => file_get_contents('image.jpg'),
);
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_URL, 'http://example.com/?image');
curl_setopt($handle, CURLOPT_POSTFIELDS, 'image={$POST_DATA['ImageData']}');
curl_setopt($handle, CURLOPT_POST, 1);
curl_close($handle);
Then in the page in which I receive the curl request...
if(isset($_REQUEST['image']))
var_dump($_FILES); // won't work because i can't get $_FILES from $_POST['image']
var_dump($_POST['image']) // will only show the image data.. i want it to show what the $_FILES variable would normally show.