2

I'm trying to add an file upload/attachment to my Sprout Form submission, but even though all the other fields are saved & the Sprout Email notification is sent - the file field remains empty - no file is uploaded & so no attachment is sent.

  • I've checked that my form contains enctype="multipart/form-data"
  • I've checked that the file type I'm trying to upload is an allowed file type for the Asset folder ie: PDF
  • I've checked that the file is a reasonable size - in this case 3KB
  • I've checked the craft log, sprout forms log & sprout email log & there are no errors.

Anyone have any ideas ? Below is my form code - what am I missing ?

<form id="careerApplication" method="post" action="" accept-charset="UTF-8" 
enctype="multipart/form-data">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="sproutForms/entries/saveEntry">
<input type="hidden" name="handle" value="careerApplication">      
<fieldset>
    {{ craft.sproutForms.displayField('careerApplication.fullName') }}
</fieldset>
<fieldset>
    <label for="fields[refNo]">Reference #</label>
    <input type="text" name="fields[refNo]" id="fields-refNo" readonly value="{{ craft.request.getParam('ref') }}" />
</fieldset>
<fieldset>
    {{ craft.sproutForms.displayField('careerApplication.email') }}
</fieldset>
<fieldset>
    {{ craft.sproutForms.displayField('careerApplication.telephone') }}
</fieldset> 
<fieldset>         
    <label for="motivation">Motivation</label>
    <textarea name="fields[motivation]" id="fields-motivation" placeholder="Motivation"></textarea>
</fieldset> 
<fieldset>
    <label for="cvUpload">Submit your CV:</label>
    <input type="file" name="fields[cvUpload]" id="fields-cvUpload" />    
</fieldset>                   
{{ craft.sproutInvisibleCaptcha.protect() }}
<input id="submit_application" name="submit_application" type="button" value="Submit Application" class="red-btn" />
</form> 
2

Figured out what my problem was: I was trying to submit the form via Ajax, that's why the submit button is set to input type="button" I changed the submit button to input type="submit" & it worked. Not 100% sure how to make it work with Ajax but pretty sure it has something to do with the way the data is serialized. I don't really need Ajax submission in this instance, so not bothering with it anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.