Hi all,
I’m using Freeform to upload a picture. I have this code.
{exp:freeform:form form_name="inschrijving" return="site/inschrijving_ok" template="inschrijving" notify="[email protected]" required="name|voornaam|phone1|email|leeftijd" file_upload ="Main Upload Directory" send_attachment="yes"}
<input name="foto" type="file" />
{/exp:freeform:form}
The form goes fine, but the file is not saved to “Main Upload Directory” and is not being sent with the mail.
Can someone help me please?
Always kind regards, M
Take a look at this part of the Freeform documentation.
You need to make the input field look like this :
<input type="file" name="file1" />
You must have the file1 part in there for it to work.
Hope that helps a bit.
Best wishes,
Mark
Hi Mark,
thx for the fast and correct answer. It works fine now 😉
Although one more thing. I can’t seem to make it required. I put file1 in my list of required fields, but when I fill it in and send the form, it keeps telling me that file1 is a required field.
Any idea about that?
Kind regards, Michel
Hi MIchel,
Hi Mark, thx for the fast and correct answer. It works fine now 😉 Although one more thing. I can’t seem to make it required. I put file1 in my list of required fields, but when I fill it in and send the form, it keeps telling me that file1 is a required field. Any idea about that? Kind regards, Michel
When you say you are making it required and then filling in the form and it says that it is a required field do you mean it is telling you that even if you choose a file?
I did a little digging and apparently File Field can not be set as required. It is not a real field type, and thus cannot be set to be required. This is why the issues occur. If you do not require the field all works fine.
An alternative in order to still require this field is to require it using javascript. I’m using some simple jQuery to do the trick for me.
I have verified with Solspace that requiring the File Field can not, and will never be able to be set so javascript really is your only alternative.
~Chris
Hiya,
Just as a quick point I don’t think that you can ever have file fields as a required field using any method other than javascript. I remember looking into this quite a while back now and never came across anything in the HTML specs or anything online. All methods either employed Javascript or Flash forms that won’t submit until you choose a file.
A great javascript to use though is http://www.livevalidation.com which has support for this type of thing and is very easy to use. Also has support for just about any other form validation routine you might need too.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.