I'm creating my first website ever, which is for my custom tshirt business. I've created a form that allows a user to submit shirt constraints, which is emailed to me upon submission.
Everything is working except for the image, which only shows the file name in text. I'm guessing that I have to specify that its a file and not text?
I've looked around for an answer similar to this, but cannot find any posts with my specific problem.
Here's what I'm using and getting text only. All other variables are set up this way then called in a string variable, $message. Sorry for the noob question
<input type="file" multiple="multiple" name="fileUpload"><br>
$Image = $_POST["fileUpload"];
Assuming you simply want to embed the picture, not send it as an attachment.
PHP uploaded files are not retrieved from $_POST array, but from $_FILE array.
Try this snippet:
$imageFile = $_FILES["fileToUpload"]["tmp_name"];
$imgEncoded = base64_encode(file_get_contents($imageFile));
and then, retrieve use it:
echo "<img alt='Embedded Image' src='data:image/png;base64,$imgEncoded' />";
or whatever your specific use case is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With