0

Question is not new but i can't make it work.I have registration form along with user registration form i also have a upload picture options.These are views

// view for user data

      <form action="<?php echo base_url('Camping_register/register') ?>" method="post">
                        <h2>Camping <span class="red"><strong>Rent Details</strong></span></h2>
                        <label for="business_name">Business Name</label>
                        <input type="text" id="business_name" name="business_name" placeholder="enter your business name">
                        <label for="rental_description">Rental Description</label>
                        <textarea type="text" id="rental_description" name="rental_description"></textarea>
                        <button type="submit" name="submit">REGISTER</button>
                        <?php
                        $message = $this->session->flashdata('msg');
                        if($message){
                        echo '<div id="error_text">' . '<strong>'.$message .'</strong>'. '</div>';
                        }   
                        ?>



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

//view for image upload

        <div class="register-container container">
            <div class="row">
                <div class="iphone span5">
                    <h4>Select files from your computer(For Camping)</h4>

             <div class = "upload-image-messages"></div>

          <?php echo form_open_multipart('upload/do_upload', array('class' => 'upload-image-form'));?>
            <div class="form-inline">
              <div class="form-group">
                <input type="file" name="uploadfile[]" accept = "image/*" multiple = "multiple" size="20" /> <br />
              </div>
              <button type="submit" value="upload" class="btn btn-sm btn-primary" name="submit">Upload files</button>
            </div>
                     <script>                   
        jQuery(document).ready(function($) {

            var options = {
                beforeSend: function(){
                    // Replace this with your loading gif image
                    $(".upload-image-messages").html('<p><img src = "<?php echo base_url() ?>img/images.png" class = "loader" /></p>');
                },
                complete: function(response){
                    // Output AJAX response to the div container
                    $(".upload-image-messages").html(response.responseText);
                    $('html, body').animate({scrollTop: $(".upload-image-messages").offset().top-100}, 150);

                }
            }; 
            // Submit the form
            $(".upload-image-form").ajaxForm(options); 

            return false;

        });
        </script>

          </form>

as we can see i have different controllers.
So i need when user click on register all the data along with image name is saved in database.I don't want to add upload button along with image form.

this is my image upload.php controller
http://pastebin.com/JcxpwTGv

We can find many tutorials form uploading user data or only images but no where we can find for submitting form as whole.

Edited by shany0786

2
Contributors
6
Replies
25
Views
1 Year
Discussion Span
Last Post by diafol
0

thnks but I don't have problem in uploading the image or user data to database but i want when user clicks on register [images+user data ]submitt altogether.

I find many tutorials for form uploading user data or only images but no where we can find for submitting form as whole.

1

You can do your multipart form with normal inputs as well as the file inputs.

<?php echo form_open_multipart('upload/do_upload', array('class' => 'upload-image-form'));?>
    <h2>Camping <span class="red"><strong>Rent Details</strong></span></h2>
    <label for="business_name">Business Name</label>
    <input type="text" id="business_name" name="business_name" placeholder="enter your business name">
    <label for="rental_description">Rental Description</label>
    <textarea type="text" id="rental_description" name="rental_description"></textarea>
    <div class="form-inline">
          <div class="form-group">
            <input type="file" name="uploadfile[]" accept = "image/*" multiple = "multiple" size="20" /> <br />
          </div>
    <button type="submit" class="btn btn-sm btn-primary" name="submit">REGISTER</button>
    </div> 
</form>

Place your js scripts just before the </body> tag. Of course you will need to send all data to one file (action). So you pick them (files and data) up there. Not knowing which framework you're using, can't say more than that.

0

I am using codeigniter is it illegal to use $this->input->post("uploadfile"); for file upload it always give me null when i click on register button

Edited by shany0786

1

Bit confused with this post. You are running 2 different queries? Assuming you have something like:

users: id | username | password ...
userimages: id | filepath | user_id ...

So after you insert the reg info to the users table, you get the last inserted id and use that to insert image data into the userimages table. After all, you are using 'multiple', so I'm assuming that the registrant can upload many files during registration submission.

Votes + Comments
yeah i am confused with this tooo actually i don't have different table for images user can upload only five images which is saved in user data table.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.