1 of 2
1
Help with file upload
Posted: 12 June 2007 11:03 AM   [ Ignore ]
Administrator
Rank
Total Posts:  4
Joined  2005-08-15

Can you help me to write the correct code to upload a photo using freeform? The following code works completely correctly, except the file upload does not go through.

Thanks!

-Eva (Posting for Gizelle)


{exp:freeform:form form_name="Salon_Silky" return="static/thank-you" required="firstName|email" notify="gizelle@lieberman.com" template="default_template" onSubmit="return checkEmail(this)"}


<table width="642" border="0" bordercolor="#87B9DC" align="center">




  <
tr>
    <
td width="215"><font class="bold">First Name*<br />

        <
input name="firstName" type="text" class="field" size="25" />
    </
font></td>
    <
td height="40" colspan="2"><font class="bold">Last Name*<br />
        <
input name="lastName" type="text" class="field" size="25" />
    </
font></td>
    <
td width="203"><p><font class="bold">Phone*<br />
          <
input name="phone1" type="text" class="field" size="12" />
    </
font></p>    </td>

  </
tr>
  <
tr>
    <
td><font class="bold">Email Address*<br />
        <
input name="email" type="text" class="field" size="25" />
    </
font></td>
    <
td colspan="2"><font class="bold">Re-Type Email Address*<br />
        <
input name="emailverify" type="text" class="field" size="25" />
    </
font></td>

    <
td><font class="bold">Age*<br />
        <
input name="age" type="text" class="field" size="5" />
    </
font></td>
  </
tr>

  <
tr>
    <
td><font class="bold">Photo<br />
<
input type="file" name="photo" id="photo" />


    </
font></td>
    <
td colspan="2"></td>

    <
td>&nbsp;</td>
  </
tr>

  <
tr>
    <
td><font class="bold">Gender*<br />
    </
font
<
select name="gender[]" />
<
option value="not_given">Select...</option>
<
option value="male">male</option>
<
option value="female">female</option>
</
select>

</
td>
    <
td width="98"><font class="bold">State/Province*<br />
        <
input name="state" type="text" class="field" size="5" />
    </
font><strong></strong> </td>
    <
td width="108"><font class="bold">ZIP/Postal Code*<br />
        <
input name="zipcode" type="text" class="field" size="10" />

    </
font><strong></strong> </td>
    <
td><font class="bold">Years suffered*<br />
        <
input name="YearsSuffered" type="text" class="field" size="15" />
    </
font></td>
  </
tr>
  <
tr>
    <
td>&nbsp;</td>
    <
td colspan="2">&nbsp;</td>

    <
td>&nbsp;</td>
  </
tr>
  <
tr>
    <
td colspan="4"><div align="right">
     <
input name="image" type="image" src="/btn_submit.gif" alt="Submit Your Story" width="83" height="20" border="0" />
    </
div></td>
  </
tr>

</
table>


{/exp:freeform:form} 

Profile
 
 
Posted: 12 June 2007 06:58 PM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  17
Joined  2007-01-28

hello Eva,

I am getting the same problem, I have a post right before you wink Freeform is aweome but it seems buggy.

Profile
 
 
Posted: 14 June 2007 03:51 AM   [ Ignore ]   [ # 2 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Personally, I have found Freeform a stable and mature program, and you can’t beat the price. The upload works for me, too, so I am going through this template line by line. The same goes for your problem, Faliol.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 14 June 2007 05:04 AM   [ Ignore ]   [ # 3 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

OK, I’ve got it to work locally, so we should be able to get this working for you, too. As a quick note, the file upload ability is rather new, and I admit that the docs could be a bit clearer at some points.  Eva, let’s take a look at Gizelle’s code, in particular the opening tag:

{exp:freeform:form form_name="Salon_Silky" return="static/thank-you" required="firstName|email" notify="gizelle@lieberman.com" template="default_template" onSubmit="return checkEmail(this)"

You need to add at least file_upload =“Main Upload Directory” so Freeform knows where to store the attachment. send_attachment=“yes” is optional, and does just what it says.

Also, the “name” attribute of the upload field needs to be file1 (file2, etc.) So instead of

<input type="file" name="photo" id="photo" /> 

please use

<input type="file" name="file1" id="file1" /> 

instead. That should work, at least it does for me. This combination was a bit hard to figure out, by the way, so apologies if it took a while.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 14 June 2007 06:19 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  17
Joined  2007-01-28

Hello Ingmar

Thanks!!! You rock! I got it working for the most part. I changed the name to the file1 like you had it and at first it did not work when I had file1 as a required field. It would say an error, that that field is required even tho I had select a file. When I took that required off it worked and the file was uploaded and emailed.

Is there a way to get it to work with the file1 required?

Thanks again!

Profile
 
 
Posted: 14 June 2007 06:21 AM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  17
Joined  2007-01-28

Here’s the error that comes up

The form you submitted contained the following errors

The following field is required
File Upload 

Profile
 
 
Posted: 14 June 2007 06:24 AM   [ Ignore ]   [ # 6 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Faliol, let me test. I haven’t tried that before. As I’ve said, the whole file upload thing for Freeform came out in April.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 14 June 2007 06:32 AM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  17
Joined  2007-01-28

Thanks Ingmar, and again, Freeform is awesome, its jsut like you said though, its a new feature and that can be quirky.

In the fields section, I have the file1 field as an input type, if that helps. Not sure if that matters.

Here’s the new code also if you need it…

{exp:freeform:form required="name_author|person_posting|company_name|wp_phone|wp_phone|wp_address|wp_city|wp_state|wp_postalcode|wp_country|wp_type_content|wp_comments|wp_disclaimer|file1" form_name="whitepapers_form" return="resources/whitepapers_thanks" notify="email removed" template="whitepapers" file_upload="Whitepapers" send_attachment="yes"}
<div class="whitepapers-form">

<
fieldset>  
<
legend>General Info</legend>  
<
ol>  
<
li>  
<
label for="name_author">Name of Author:</label>  
<
input id="name_author" name="name_author" class="text" type="text" />  
</
li>  
<
li>  
<
label for="person_posting">Name of Person Posting:</label>  
<
input id="person_posting" name="person_posting" class="text" type="text" />  
</
li>  
<
li>  
<
label for="company_name">Company Name:</label>  
<
input id="company_name" name="company_name" class="text" type="text" />  
</
li>
<
li>  
<
label for="wp_phone">Phone:</label>  
<
input id="wp_phone" name="wp_phone" class="text" type="text" />  
</
li>
<
li>  
<
label for="wp_email">Email:</label>  
<
input id="wp_email" name="wp_email" class="text" type="text" />  
</
li
<
li
<
label for="wp_address">Street Address:</label>  
<
input id="wp_address" name="wp_address" class="text"  type="text" />  
</
li>  
<
li>  
<
label for="wp_city">City:</label>  
<
input id="wp_city" name="wp_city" class="text"  type="text" />  
</
li>  
<
li>  
<
label for="wp_state">State:</label>  
<
input id="wp_state" name="wp_state" class="text"  
type="text" />  
</
li>  
<
li>  
<
label for="wp_postalcode">Postal Code:</label>  
<
input id="wp_postalcode" name="wp_postalcode"  
class="text" type="text" />  
</
li>
 
<
li>  
<
label for="wp_country">Country:</label>  
<
input id="wp_country" name="wp_country" class="text" type="text" />  
</
li


</
ol>  
</
fieldset>


<
fieldset>  
<
legend>File Upload</legend>  
<
ol>  
<
li>  
<
label for="wp_type_content">Type of Content:<br />
<
span style="font-weight: normal; font-size: .9em;">(Brief Description)</span></label>  
<
textarea id="wp_type_content" name="wp_type_content" style="width: 180px;height: 100px;"></textarea>
</
li>  
<
li>  
<
label for="wp_keywords">Associated Keywords:<br />
<
span style="font-weight: normal; font-size: .9em;">(separate each by commas)</span>
</
label>  
<
input id="wp_keywords" name="wp_keywords" class="text"  
type="text" />  
</
li>  
<
li>  
<
label for="wp_comments">Comments:</label>  
<
textarea id="wp_comments" name="wp_comments" style="width: 180px;height: 160px;"></textarea>
</
li>  

 <
li>  
<
label for="file1" style="float: none;width: 340px; text-align: left;">Attach Word Doc or PDF:</label>  
<
input type="file" name="file1" id="file1"  size="40" style="width: 300px;">
</
li>

 <
li
<
label for="wp_disclaimer" style="float: none;width: 340px; text-align: left;">Disclaimer:</label>  
<
input type="radio" name="wp_disclaimer" id="wp_disclaimer" value="Author Consent" /> I am the author of this paper and give my consent for Channelpro to publish the content.<br />
<
input type="radio" name="wp_disclaimer" id="wp_disclaimer" value="Written Permission" /> I know the author and have written permission to post the content for publishing by Channelpro.<br />


</
li>

</
ol>  
</
fieldset>



<
p style="text-align: center;">
{if captcha}

For security purposesplease enter the word you see in the image below:<br />

{captcha}<br />
<
input type="text" name="captcha" value="" maxlength="20" />

{/if}
</p>

<
fieldset class="submit">  
<
input class="submit" type="submit" value="Submit" />  
</
fieldset>
</
div>
{/exp:freeform:form} 

Profile
 
 
Posted: 14 June 2007 06:58 AM   [ Ignore ]   [ # 8 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

No, I can’t get it to work, either. I believe this is a bug, or at least room for improvement. I’ll make the necessary requests.

Sorry, for the time being you cannot use the Freeform module to force the user to attach a file.  I have tried using the onSubmit extension with Freeform, though,  and initial results are promising. So, if you know a little Javascript, you can check whether the file upload field has indeed been filled out, or not. This extension normally costs 5$, but in your case it’s on the house. It has been added to your account.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 26 June 2007 08:26 PM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  2
Joined  2007-06-26

Having a similar problem, can’t find the right answer after looking through the documentation and the forums

{exp:freeform:form form_name=“Become_a_model_form” return=“weblog/Women” file_upload =“uploads” send_attachment=“yes” notify=“email removed” required=“name|from” onSubmit=“return checkEmail(this)“ template=“default_template”}

Name

<input type=“text” id=“name” name=“name” class=“input3” style=“width:180px;“ value=“{member_name}“ />


Email

<input type=“text” id=“from” name=“from” class=“input3” style=“width:180px;“ value=“{member_email}“ />


Age

<select name=“age[]“  >
<option value=“”> Select Age </option>
                          <option value=“14”>14
                          <option value=“15”>15
                          <option value=“16”>16
                          <option value=“17”>17
                          <option value=“18”>18
                          <option value=“19”>19
                          <option value=“20”>20
                          <option value=“21”>21
                          <option value=“22”>22
                          <option value=“23”>23
                          <option value=“24”>24
                          <option value=“25”>25
                          <option value=“26”>26
                          <option value=“27”>27
                          <option value=“28”>28
                          <option value=“29”>29
                          <option value=“30”>30
                          <option value=“31”>31
                          <option value=“32”>32
                          <option value=“33”>33
                          <option value=“34”>34
                          <option value=“35”>35
                          <option value=“36”>36
                          </select>


Age

<select name=“gender[]“  >
<option value=“” selected> choose>>>                        </option>
                        <option value=“Female”>Female</option>
                        <option value=“Male”>Male</option>
                      </select>

Your Photo

<input type=“file” name=“file1” id=“file1” />

 

{if captcha}

For security purposes, please enter the word you see in the image below:


{captcha}

<input type=“text” name=“captcha” value=“” maxlength=“20” />

{/if}

 

<input type=“submit” name=“submit” value=“submit” />


{/exp:freeform:form}

Profile
 
 
Posted: 27 June 2007 01:54 AM   [ Ignore ]   [ # 10 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

OK, let’s break this down to the basic form, makes it easier to troubleshoot.

{exp:freeform:form form_name="Become_a_model_form" file_upload ="uploads"}
<input type="file" name="file1" />
{/exp:freeform:form} 

If you put that in a template, does it work? If not, what error message do you get, if any? Is “uploads” the correct name for the upload directory, as set in the EE control panel? (The default is
“Main Upload Directory”)

 Signature 

Ingmar Greil

Profile
 
 
Posted: 27 June 2007 03:29 AM   [ Ignore ]   [ # 11 ]
Newbie
Rank
Total Posts:  2
Joined  2007-06-26

Thanks, as it turns out by using the basic form I got an error message showing that the maximum files size was being exceeded.  I did not get this message when using the form I built.  Anyhow, I modified the size and its working fine.

Thanks again

Morris

Profile
 
 
Posted: 27 June 2007 07:45 AM   [ Ignore ]   [ # 12 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

That’s good news. We were slowly running out of options, as it were.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 27 June 2007 12:59 PM   [ Ignore ]   [ # 13 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Just for reference, and to bundle all the “file upload” issues in one thread… This will not work with attachments, though it does not produce an error message, and seems to work on the non-attachment part:

<input name="image" type="image" src="submit.gif" alt="Submit Your Story" width="83" height="20" border="0" /> 

it needs to be:

<input name="submit" type="image" src="submit.gif" alt="Submit Your Story" width="83" height="20" border<