I am trying to allow users on my website to upload an image with a form. I have been using formspree (https://formspree.io/) I receive the name of the image but no image attached to the email.
I'm using:
<label>
Upload Photo
<input type="file" name="uploadField" />
</label>
Has anyone managed to do this?
Formspree currently doesn't support file inputs, but Formsprees FAQ has this advice:
For almost zero work and cheap (or free) prices you can integrate external file upload services into a Formspree form. Uploadcare is one example. If you just create an account and include their widget:
<!-- The best place for this one is your <HEAD> tag -->
<script>UPLOADCARE_PUBLIC_KEY = "demopublickey";</script>
<script
src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"
charset="utf-8"></script>
<!-- This is where the widget will be. Don't forget the name attribute! -->
<input type="hidden" role="uploadcare-uploader" name="my_file" />
Per their documentation, you can use that inside the Formspree form and receive the URL of the document in your email address.
Source: https://help.formspree.io/articles/6199-how-to-do-file-uploads-with-formspree
I'm pretty sure the issue is your enctype
isn't defined. Here's an example using a basic HTML form (you'll need some PHP/server side code to process the file):
<form action="your_script.php" method="post" enctype="multipart/form-data">
Image: <input type="file" name="uploadField" />
<input type="submit" value="Submit">
</form>
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