I am trying to build a contact form with Netlify Forms (and Alpine JS) but the file upload part is not working. In the Netlify backend I have it setup for forward the messages from this form submission to an email address but none of the images make it through. I have verified with Chrome developer tools that the images are being posted to the server.
Originally I had a tried using name="photos[]"
but I saw another message that this was not supported so I switched it use different names for each image name="photo1"
, name="photo2"
, etc.
<form name="contact" action="/" method="POST" enctype="multipart/form-data" netlify>
<div class="col-md-6 col-sm-12">
<div class="block">
<div class="form-group">
<input name="name" type="text" class="form-control" placeholder="Your Name" required>
</div>
<div class="form-group">
<input name="email" type="text" class="form-control" placeholder="Email Address" required>
</div>
<div class="form-group">
<input name="size" type="text" class="form-control" placeholder="Square feet" required>
</div>
<div class="form-group">
<input name="phone" type="text" class="form-control" placeholder="Phone" required>
</div>
<div class="form-group">
<select name="category" class="form-control">
<option disabled selected>Category</option>
<option>Landscaping</option>
<option>Hardscaping</option>
<option>Cleaning</option>
<option>Sealing & Coatings</option>
</select>
</div>
<div x-data="{ count: 1 }">
<template x-for="i in count">
<div class="form-group">
<input type="file" :name="'photo' + i">
</div>
</template>
<div class="form-group">
<button type="button" class="btn btn-main" @click="count++">Add photo</button>
<p class="help-block">Upload a picture of your project.</p>
</div>
</div>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="block">
<div class="form-group">
<textarea name="job_address" class="form-control" placeholder="Your address" required></textarea>
</div>
<div class="form-group">
<textarea name="user_message" class="form-control" placeholder="What would you like done?" required></textarea>
</div>
<div class="form-group block">
<button type="submit" class="btn btn-main">{{ i18n "submit" }}</button>
</div>
<div class="form-group">
<div netlify-recaptcha></div>
</div>
</div>
</div>
</form>