Welcome Guest, Not a member yet? Register   Sign In
codeigniter validation
#1

Dear all,

I have below that will post several images to the php apache server.
I have used the codeigniter validation. If I used below code, the images cannot post to server. If I comment the form_open(......) code "<?php $prevURLPATH=urlencode($prevURL); echo form_open('newPost/createNewPost/'.$userID.'/'.$username.'?prevURL='.$prevURLPATH); ?>", It can post but without codeigniter validation. If I want to be able to post images and using codeigniter validation, what the below code should be amended??


Code:
<div id="wrapper">
   <div class="main-container">
    <div class="container">
     <?php echo validation_errors("<div style='color:red;'>","</div>"); ?>

   <?php $prevURLPATH=urlencode($prevURL); echo form_open('newPost/createNewPost/'.$userID.'/'.$username.'?prevURL='.$prevURLPATH);  ?>
      <div class="row">
        <div class="col-md-9 page-content">
          <div class="inner-box category-content">
            <div class="row">
              <div class="col-sm-12">
                 <form id="newPost" class="form-horizontal" method="post" enctype="multipart/form-data"
                      action="<?php echo base_url(); echo MY_PATH;?>newPost/createNewPost/<?php echo $userID.'/'.$username.'?prevURL='.urlencode($prevURL); ?>">
                  <fieldset>
                 ………….
…………………………………
            <div class="form-group row">
                          <label class="col-md-3 control-label text-center" for="textarea">
                              <i class="icon-camera-1"></i><abbr title="Min. 1 picture required. Max. 5 pictures allowed. Max. picture file size 4MB per each. First Picture is the default that will show to customer first."><?php echo $Picture;?></abbr><font color="red">*</font></label>
                          </label>
                           <div class="col-md-8">
                              <div class="mb10">
                                  <input id="image" name="images[]" class="file" type="file" accept="image/*" multiple>
                                    <div id="uploadImgError">
                                    </div>
                              </div>
                                  <p class="help-block">Add up to 5 photos. Use a better image of your product, not catalogs.</p>  
                          
                          </div>
                      </div>


            div class="form-group row">
                          <label class="col-md-3 control-label text-center"></label>
                          <div class="col-md-8">
                                  <button id="submit-upload-form"  class="btn btn-primary btn-tw" onclick="setup(); return false;"><i class="glyphicon glyphicon-upload"></i>Submit</button>
                              <button id="validate" hidden="true" type="submit"></button>
                          </div>
                       </div>
                  </fieldset>

            </form>
                
                
              </div>
            </div>
          </div>
        </div>
</div>
</div>
</div>
</div>
Reply
#2

(04-14-2016, 05:59 AM)rchiu5hk Wrote: Dear all,

I have below that will post several images to the php apache server.
I have used the codeigniter validation. If I used below code, the images cannot post to server. If I comment the form_open(......) code "<?php $prevURLPATH=urlencode($prevURL); echo form_open('newPost/createNewPost/'.$userID.'/'.$username.'?prevURL='.$prevURLPATH);  ?>", It can post but without codeigniter validation. If I want to be able to post images and using codeigniter validation, what the below code should be amended??


Code:
<div id="wrapper">
  <div class="main-container">
   <div class="container">
    <?php echo validation_errors("<div style='color:red;'>","</div>"); ?>

  <?php $prevURLPATH=urlencode($prevURL); echo form_open('newPost/createNewPost/'.$userID.'/'.$username.'?prevURL='.$prevURLPATH);  ?>
     <div class="row">
       <div class="col-md-9 page-content">
         <div class="inner-box category-content">
           <div class="row">
             <div class="col-sm-12">
                <form id="newPost" class="form-horizontal" method="post" enctype="multipart/form-data"
                     action="<?php echo base_url(); echo MY_PATH;?>newPost/createNewPost/<?php echo $userID.'/'.$username.'?prevURL='.urlencode($prevURL); ?>">
                 <fieldset>
                ………….
…………………………………
<div class="form-group row">
                      <label class="col-md-3 control-label text-center" for="textarea">
                             <i class="icon-camera-1"></i><abbr title="Min. 1 picture required.
Max. 5 pictures allowed.
Max. picture file size 4MB per each.
First Picture is the default that will show to customer first."><?php echo $Picture;?></abbr><font color="red">*</font></label>
                         </label>
                          <div class="col-md-8">
                             <div class="mb10">
                                 <input id="image" name="images[]" class="file" type="file" accept="image/*" multiple>
                                   <div id="uploadImgError">
                                   </div>
                             </div>
                                 <p class="help-block">Add up to 5 photos. Use a better image of your product, not catalogs.</p>  
                         
                         </div>
                     </div>


div class="form-group row">
                         <label class="col-md-3 control-label text-center"></label>
                         <div class="col-md-8">
                            <button id="submit-upload-form"  class="btn btn-primary btn-tw" onclick="setup(); return false;"><i class="glyphicon glyphicon-upload"></i>Submit</button>
                             <button id="validate" hidden="true" type="submit"></button>
                         </div>
                      </div>
                 </fieldset>

</form>
               
               
             </div>
           </div>
         </div>
       </div>
</div>
</div>
</div>
</div>

You have two forms in you code. <?= form_open(...)?> = <form ...>
The html code is wrong. Reread you code and set the open/close tag right. Can you give us the controller code?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB