The server along with PHP before running your script has already parse the PAYLOAD and saved the image to the ./tmp
folder set by php.ini at upload_tmp_dir
", then you can upload normally and use file_get_contents
, a basic example would be:
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="arquivo" multiple>
<button type="submit">Upload</button>
</form>
And php would be:
<?php
if (empty($_FILES['arquivo']['tmp_name'])) {
die('Erro no upload');
}
//Pega os dados do upload
$dados_da_imagem = file_get_contents($_FILES['arquivo']['tmp_name']);
If you want to display on the screen you will need to use data URI scheme a>, something like:
$dados_da_imagem = file_get_contents($_FILES['arquivo']['tmp_name']);
echo '<img src="data:image/gif;base64,', base64_encode($dados_da_imagem),'">';
Now if your intention is to preview the image before completing the upload, I recommend that you do this on the front-end before sending the POST, example of JavaScript tools: