Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
hello, I have used the godaddy version of emailex.php (in download emailex_godaddy.zip) from http://www.couchcms.com/forum/viewtopic.php?f=8&t=6959&start=0 and have got the form working OK with an attachment. Problem is that now if I try to send the form without an attachment I get an error "Attach CV: Input of file type named 'my_file_ex' not found". Sorry to say I'm not able to amend the code myself to allow the form to send without an attachment. Can somebody else help? Thanks!
Code: Select all
<cms:input 
   type="hidden"
   name="my_file"
   required='1'
   validator='EmailEx::validate=max_size:512&allowed_ext:jpeg,jpg,gif,png'
   value='1'
/>


Hi :) Could you please try to test for the error without required='1' in the editable above?
hi trendoman, the input was already set up like this:

<cms:input
type="hidden"
label='Attach CV'
name="my_file"
required='0'
validator='EmailEx::validate=max_size:512&allowed_ext:doc,txt,zip,pdf'
value='1'
/>

I have also tried it without the 'required' parameter at all - and get the same result.
Thanks for update!
Code: Select all
EmailEx::send_mail( 'sender@mail.com', 'receiver@mail.com', 'Subject', 'Message' );

Do you use code above to send mail without attachment? In the addon it is strictly put to raise errors if file is not set.
I suggest to use some simple conditional statement to check if the file is present. If so, then use code above. If not - move to standard send_mail. EmailEx falls back to send_mail, as it seems from the code, but requires a file no matter what. Can you try this suggestion too?
@potato,
as @trendoman mentioned, the validate routine expects a file to be uploaded, so in a sense it is always 'required'.

I think you can simply edit the emailex.php file, find the following statement -
Code: Select all
return KFuncs::raise_error( "Input of file type named '".$input_name."' not found" );

- and comment it out i.e. prepend it with double-slashes to make it as follows -
Code: Select all
//return KFuncs::raise_error( "Input of file type named '".$input_name."' not found" );

Nothing else needs to be changed and the mails should go through even without the attachments.

Does this help?
@kk - yes it does help! Working with/without attachments delighted to report! Thanks both for your help.
what if you have 5 file uploads. how can you make the other 4 to be optional??

i have 5 file uploads and working properly..

one thing i can't figure out is how i can make the other 4 file upload "optional" , or all of them...

i have these..

Code: Select all
<div class="send">
      <input type="file" name="my_file_ex">
      <input type="file" name="my_file2_ex">
      <input type="file" name="my_file3_ex">
      <input type="file" name="my_file4_ex">
      <input type="file" name="my_file5_ex">
     </div>    
     <br />
    
      <cms:input
         type="hidden"
         name="my_file"
         required='1'
         validator='EmailEx::validate=max_size:10000&allowed_ext:jpeg,jpg,gif,png,txt'
         value='1'
      />
    
     <cms:input
         type="hidden"
         name="my_file2"
         required='0'
         validator='EmailEx::validate=max_size:10000&allowed_ext:jpeg,jpg,gif,png,txt'
         value='1'
      />
    
     <cms:input
         type="hidden"
         name="my_file3"
         required='0'
         validator='EmailEx::validate=max_size:10000&allowed_ext:jpeg,jpg,gif,png,txt'
         value='1'
      />
    
     <cms:input
         type="hidden"
         name="my_file4"
         required='0'
         validator='EmailEx::validate=max_size:10000&allowed_ext:jpeg,jpg,gif,png,txt'
         value='1'
      />
    
     <cms:input
         type="hidden"
         name="my_file5"
         required='0'
         validator='EmailEx::validate=max_size:10000&allowed_ext:jpeg,jpg,gif,png,txt'
         value='1'
      />


i tried to put required='0' but they are still required on submit.


any solution? thanks in advance..
Hello and welcome @kenkaen :)

Assuming you are using the godaddy specific script -
instead of commenting out the line, as I suggested to @potato above, please find the line
Code: Select all
return KFuncs::raise_error( "Input of file type named '".$input_name."' not found" );

and make it as follows -
Code: Select all
if( $field->required ){
    return KFuncs::raise_error( "Input of file type named '".$input_name."' not found" );
}

Does this help?
Yes it Works!

Thank you for the welcome and quick response! @KK
Hi

I successfully implemented a form and could send an attachment on my local server. Unfortunately it does not work online. The files are exactly the same. Any idea why this does not work?

Regards,
olliwalli
13 posts Page 1 of 2