We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Freeform + Attachment

Development and Programming

webnology's avatar
webnology
352 posts
16 years ago
webnology's avatar webnology

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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

       
webnology's avatar
webnology
352 posts
16 years ago
webnology's avatar webnology

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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?

       
webnology's avatar
webnology
352 posts
16 years ago
webnology's avatar webnology

Indeed.

       
Neil Evans's avatar
Neil Evans
1,374 posts
15 years ago
Neil Evans's avatar Neil Evans

same issue here… file field - if required - does not detect correctly…

       
chealey's avatar
chealey
95 posts
15 years ago
chealey's avatar chealey

Have the same problem. Any word?

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

This isn’t an EE question, have any of you posted on Solspace’s forum for an answer?

       
chealey's avatar
chealey
95 posts
15 years ago
chealey's avatar chealey

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
15 years ago
Mark Bowen's avatar Mark Bowen

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

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.