I am having an issue with a Databound Form which allows for front-end upload of images.
For the form, if a front-end user submits an image which is larger than the max_size='1000000' value, the form does not return an error, but rather a "Success" message. However, on the back end, the entry does not appear—which means the front-end user thinks their post was successful even though it was not.
Is there a way to validate the size of the uploaded image, either by dimensions or file size, that will provoke an error if the front end user is out of the bounds of what is allowable?
See this form for example:
https://rediscovermylife.org/ican_form.php
Here is the code for the editables portion:
and here is the code for the form itself:
For the form, if a front-end user submits an image which is larger than the max_size='1000000' value, the form does not return an error, but rather a "Success" message. However, on the back end, the entry does not appear—which means the front-end user thinks their post was successful even though it was not.
Is there a way to validate the size of the uploaded image, either by dimensions or file size, that will provoke an error if the front end user is out of the bounds of what is allowable?
See this form for example:
https://rediscovermylife.org/ican_form.php
Here is the code for the editables portion:
- Code: Select all
<?php require_once( 'community/cms.php' ); ?>
<cms:template title='iCan' clonable='1'>
<cms:editable name='ican_ambassador_email' label='Ambassador Email Address' type='text' required='1' />
<cms:editable name='ican_ambassador_name' label='Ambassador Name' type='text' required='1' />
<cms:editable name='ican_ambassador_location' label='Location' desc='City and State Initials' type='text' />
<cms:editable name='ican_ambassador_interests' label='Interests' type='text' />
<cms:editable
name="ican_ambassador_procedure"
label="Procedure"
desc="Select One"
opt_values='Cervical Disc Replacement | Lumbar Disc Replacement | Cervical and Lumbar Disc Replacement | Cervical Spinal Fusion | Lumbar Spinal Fusion '
type='dropdown'
required='1'
/>
<cms:editable name='ican_ambassador_age' label='Age' type='text' />
<cms:editable name='ican_ambassador_surgerydate' label='Surgery Month and Year' desc='i.e. October 2018' type='text' />
<cms:editable name="ican_post_image" required='1' allowed_ext='jpg, jpeg, png, gif' max_size='1000000' type='securefile' label='Post Image' />
<cms:editable name='ican_ambassador_post' label='Post' desc='Tell Your Story' type='textarea' required='1' />
<cms:editable name='ican_acknowledgment' label='Terms & Conditions Acknowledgement' desc='The User has Read the Terms and Conditions' type='checkbox' required='1' opt_values='Yes' />
<cms:editable name='ican_approvalstatus' label='Approval Status' desc='Check to Make the Post Live' type='checkbox' opt_values='Approved' />
</cms:template>
and here is the code for the form itself:
- Code: Select all
<cms:form
masterpage=k_template_name
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>
<cms:if k_success >
<cms:check_spam email=frm_email />
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
/>
<cms:set_flash name='submit_success' value='1' />
<cms:send_mail from='forms@rediscovermylife.org' to='jms307@nyu.edu, j.silvermintz@centinelspine.com' subject='A New I CAN Entry has been Submitted for Approval.' html="1">
A new <i>'I Can'</i> entry has been submitted on re<b>disc</b>over. Below are some quick details:
<br><br>
<b>Patient Name:</b><br>
<cms:show frm_ican_ambassador_name />
<br><br>
<b>Patient Story:</b><br>
<cms:show frm_ican_ambassador_post />
<b>Patient Email Address:</b><br>
<cms:show frm_ican_ambassador_email />
</cms:send_mail>
<cms:redirect k_page_link />
</cms:if>
<cms:if k_error >
<div class="alert alert-danger" role="alert" style="text-transform:capitalize; padding:30px; margin-bottom: 60px; font-size: 18px;">
<cms:each k_error >
<cms:show item />
</cms:each>
</div>
</cms:if>
<cms:if k_error_email >
<div class="alert alert-danger" role="alert" style="text-transform:capitalize; padding:30px; margin-bottom: 60px; font-size: 18px;">
Please enter a valid email address.
</div>
</cms:if>
<div class="row">
<div class="col-md-4" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Email Address <span class="asterisk" style="color:red;">*</span></h5>
<p style="font-size: 13px;">(i.e. user@gmail.com)</p>
<cms:input name="ican_ambassador_email" type="bound" style="width:100%" validator='email' />
</div>
<div class="col-md-4" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Name <span class="asterisk" style="color:red;">*</span></h5>
<p style="font-size: 13px;">(i.e. First Name & Initial)</p>
<cms:input name="ican_ambassador_name" type="bound" style="width:100%" />
</div>
<div class="col-md-4" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Procedure<span class="asterisk" style="color:red;">*</span></h5>
<p style="font-size: 13px;">(Select One from the Dropdown)</p>
<cms:input name="ican_ambassador_procedure" type="bound" style="width:100%" />
</div>
</div>
<hr>
<div class="row">
<div class="col-md-3" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Location</h5>
<p style="font-size: 13px;">(i.e. City & State)</p>
<cms:input name="ican_ambassador_location" type="bound" style="width:100%" />
</div>
<div class="col-md-3" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Interests</h5>
<p style="font-size: 13px;">(i.e. Hiking, Gardening, Etc.)</p>
<cms:input name="ican_ambassador_interests" type="bound" style="width:100%" />
</div>
<div class="col-md-3" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Age</h5>
<p style="font-size: 13px;">(Not Required)</p>
<cms:input name="ican_ambassador_age" type="bound" style="width:100%" />
</div>
<div class="col-md-3" style="margin-bottom:30px;">
<h5 style="margin-bottom: 2px;">Surgery Date</h5>
<p style="font-size: 13px;">(Enter the Month & Year, i.e. May 2022)</p>
<cms:input name="ican_ambassador_surgerydate" type="bound" style="width:100%" />
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12" style="margin-bottom:30px;">
<h5>Post Image <span class="asterisk" style="color:red;">*</span></h5>
<p style="font-size: 13px;">(Images should be a maximum width and/or height of 2048px)</p>
<cms:input name="ican_post_image" type="bound" class="btn btn-video" />
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12" style="margin-bottom:30px;">
<h5>Tell Your <span style="font-style: italic; margin-right: 5px;">'I Can'</span> Story <span class="asterisk" style="color:red;">*</span></h5>
<cms:input name="ican_ambassador_post" type="bound" class="textarea-form" />
</div>
</div>
<div class="row">
<div class="col-md-6" style="margin-bottom:30px;">
<h5>I agree to the <a data-toggle="modal" data-target="#iCanTerms">Terms and Conditions</a>. <span class="asterisk" style="color:red;">*</span></h5>
<cms:input name="ican_acknowledgment" type="bound" style="margin-right:5px;" />
</div>
<div class="col-md-6" style="margin-bottom:30px;">
<h5>What color is a red apple? <span class="asterisk" style="color:red;">*</span> <a data-toggle="tooltip" style="color:#666;" data-placement="top" data-original-title="This question is used to prevent spam. The answer is red, of course."><i style="font-size: 13px; margin-left: 5px;" class="glyphicon glyphicon-question-sign"></i></a></h5>
<cms:input name="attention" type="text" required='1' validator='regex=/^red$/i' style="width:100%" />
</div>
</div>
<div class="row" style="margin-bottom: 60px;">
<div class="col-md-12" style="margin-bottom:30px;">
<cms:if "<cms:not submit_success />" >
<button type="submit" value="Submit My Information" class="btn" style="margin-top: 20px;">Submit My Story</button>
</cms:if>
</div>
</div>
</cms:form>
</div>