Welcome Guest, Not a member yet? Register   Sign In
Multile File upload, I give up.
#1

[eluser]mabright[/eluser]
I am almost done with my internal message system but I am stuck on attaching a file to a message. I have a view called compose, where a user composes a internal message. I am using the JQuery Mutile File upload java-script and this works fine, I can see the files on the screen as I add them.

In my messages controller, method compose calls methos "send" when the message is submitted. From here I call do_upload and then send the message but no file is uploaded to my server and no error message is returned.

Form
Code:
<div id="mc_container">
    &lt;form method="post" action="&lt;?php echo current_url().'/send'; ?&gt;" enctype="multipart/form-data" /&gt;
        <div id="msg_compose">
                <ol>
                    <li>
                        &lt;?php echo validation_errors(); ?&gt;
                        <p class="error_text">&lt;?php echo $this->session->flashdata('message'); ?&gt;</p>
                    </li>
                    <li>
                        <label class="label_required">From:</label>
                        <p>&lt;?php echo $this->session->userdata('username'); ?&gt;</p>
                    </li>
                    <li>
                        <label class="label_required">To:
                            &lt;?php
                            $atts = array('width'      => '500',
                                          'height'     => '400',
                                          'scrollbars' => 'no',
                                          'status'     => 'no',
                                          'resizable'  => 'no',
                                          'screenx'    => '0',
                                          'screeny'    => '0');
                            echo anchor_popup('member/messages/member_search/recipients', img('images/icons/magnifier.png'), $atts);
                            ?&gt;
                        </label>
                        &lt;input class="msg_compose_input" type="text" name="input_recipients" id="input_recipients" value="&lt;?php echo set_value('input_recipients[]'); ?&gt;" tabindex="1"/&gt;
                        &lt;?php echo form_error('input_recipients'); ?&gt;
                    </li>
                    <li>
                        <label class="label_required">CC:
                        &lt;?php
                            $atts = array('width'      => '500',
                                          'height'     => '400',
                                          'scrollbars' => 'no',
                                          'status'     => 'no',
                                          'resizable'  => 'no',
                                          'screenx'    => '0',
                                          'screeny'    => '0');
                            echo anchor_popup('member/messages/member_search/cc', img('images/icons/magnifier.png'), $atts);
                            ?&gt;    
                        </label>
                        &lt;input class="msg_compose_input" type="text" name="input_cc" id="input_cc" value="&lt;?php echo set_value('input_cc[]'); ?&gt;" tabindex="2"/&gt;                    
                    </li>
                    <li>
                        <label class="label_required">Subject:</label>
                        &lt;input class="msg_compose_input" type="text" name="input_msg_subject" id="input_msg_subject" value="&lt;?php echo set_value('input_subject'); ?&gt;" tabindex="3"/&gt;
                    </li>
                    <li>
                        <label class="label_required">&lt;?php echo img('images/attach.png'); ?&gt;</label>
                    </li>
                    <li>
                        &lt;textarea class="msg_compose_textarea" name="input_msg_body" id="input_msg_body" TABINDEX="4"&gt;&lt;?php echo set_value('input_msg_body'); ?&gt;&lt;/textarea&gt;
                    </li>
                    <li>
                        <p class="msg_field_note">Allowed file types: gif, jpg. Max Size: 2M. 3 Files Max.</p>
                        <label class="label_required">Attachment:</label>
                        &lt;input type="file" name="msgfile[]" class="multi" maxlength="3" accept="gif|jpg" tabindex="5"/&gt;                    
                    </li>
                    <li>
                        <label class="nolabel">.</label>
                        &lt;input name="send_msg" class="button" type="submit" value="Send Message" /&gt;
                    </li>
                </ol>
        </div>
    &lt;/form&gt;
</div>        
&lt;?php
/* End of file message_compose_view.php */

Controller method send()
Code:
public function compose($action = '')
    {
        $msg_data = array('inbox_count' => $this->inbox_count,
                          'sent_count' => $this->sent_count,
                          'trash_count' => $this->trash_count);                                  
        
        if(!$action || $this->form_validation->run() == FALSE)
        {
            $data['column_main'] = $this->load->view('member/message_compose_view', $msg_data, TRUE);
            $this->_display('',$data);
        }
        elseif(strtoupper($action) == 'SEND')
        {
            $this->send();
        }
        elseif(strtoupper($action) == 'PREVIEW')
        {
            $this->preview();
        }        
    }

    private function send()
    {
        $has_attachment = '';
        
        $msg_data = array('inbox_count' => $this->inbox_count,
                          'sent_count' => $this->sent_count,
                          'trash_count' => $this->trash_count);
                          
      //Upload attachment file(s) to server        
      $this->load->library('upload');
      $this->upload->do_upload();

         ......send message, link to uploaded files, etc.
}




Theme © iAndrew 2016 - Forum software by © MyBB