• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't Upload image with 1.7.2

#1
[eluser]Unknown[/eluser]
i am using codeingniter 1.7.2. i have tried so many times to upload an image but
somehow the code is not working for me. i have also loaded url helper and library. And there is no error i can see after clicking submitting button.

I have created my image folder to the root directory.

Please help me.





view.php:
Code:
<h2>Submit A Company </h2>
<table id="submitform">
&lt;?php echo form_open_multipart('submit/insert');?&gt;
<tbody><tr >
<td width="150"><span class="ip_text">Business or Company Name</span><font color="red">&nbsp;*</font></td>
<td class="ip_text" valign="top">
    &lt;?php echo form_input(array('id'=>'company_name','name' =>'companyname','value' =>'insert your company name'));?&gt;
    </td></tr>
  <tr >
<td width="150"><span class="ip_text">Service or Specialization</span></td>
<td class="ip_text" valign="top">
     &lt;?php echo form_input(array('id'=>'service','name' =>'service','value' =>'insert your Service'));?&gt;
     <tr >
<td valign="top" width="150"><span class="ip_text">Description</span></td>
<td class="ip_text" valign="top">
     &lt;?php echo form_textarea(array('id'=>'description','name' =>'description','row'=>'5','cols'=>'45','value' =>'insert your descrioption here'));?&gt;
</td></tr>

  <tr >
<td width="150"><span class="ip_text">Keywords</span></td>
<td class="ip_text" valign="top">
     &lt;?php echo form_input(array('id'=>'keyword','name' =>'keyword','value' =>'type some keyword'));?&gt;
    <br><small><span class="ip_text">Please, type keywords separated by comma</span></small></td></tr>
  <tr>
    <td><h2>Overview:</h2></td>
  </tr>
  <tr >
<td width="150"><span class="ip_text">Logo</span></td>

<td class="ip_text" valign="top"><table border="0" cellpadding="2" cellspacing="4">  
        <tbody><tr>  
                <td colspan="4">
                    &lt;input type="file" name="userfile" size="20" /&gt;
                    &lt;?php echo form_upload(array('id' =>'upload','name'=>'upload'));?&gt;
                  </td>  </tr></tbody>
    </table><br><small><span class="ip_text">gif, jpeg, png formats supported</span></small></td></tr>
  <tr >
<td width="150"><span class="ip_text">Address</span><font color="red">&nbsp;*</font></td>
<td class="ip_text" valign="top">
     &lt;?php echo form_input(array('id'=>'address','name' =>'address','value' =>'type address'));?&gt;
</td></tr>
  <tr >
<td width="150"><span class="ip_text">City</span><font color="red">&nbsp;*</font></td>
<td class="ip_text" valign="top">
    
    &lt;?php

$dd_list = array(
     '' => '<-- Select --&gt;',
    
     'Bagerhat'=>'Bagerhat',
     'Bandarban'=>'Bandarban',
     'Barguna'=>'Barguna',
     'Barishal'=>'Barishal',
     'Bogra'=>'Bogra',
     'Chandpur'=>'Chandpur',
     'Chittagong'=>'Chittagong',
     'Comilla'=>'Comilla',
    
    
     'Coxs Bazar'=>'Coxs Bazar',
     'Dhaka'=>'Dhaka',
     'Dinajpur'=>'Dinajpur',
     'Faridpur'=>'Faridpur',
     'Feni'=>'Feni',
     'Gazipur'=>'Gazipur',
     'Jamalpur'=>'Jamalpur',
     'Jessore'=>'Jessore',
     'Jhalakathi'=>'Jhalakathi',
    
     'Jhenaidah'=>'Jhenaidah',
     'Khulna'=>'Khulna',
     'Kishoregonj'=>'Kishoregonj',
     'Kurigram'=>'Kurigram',
     'Kushtia'=>'Kushtia',
     'Moulvibazar'=>'Moulvibazar',
     'Mymensingh'=>'Mymensingh',
     'Naogaon'=>'Naogaon',
     'Narayanganj'=>'Narayanganj',
     'Narsingdhi'=>'Narsingdhi',
     'Natore'=>'Natore',
     'Noakhali'=>'Noakhali',
         'Pabna'=>'Pabna',
         'Rajshahi'=>'Rajshahi',
         'Rangamati'=>'Rangamati',
         'Rangpur'=>'Rangpur',
         'Satkhira'=>'Sirajgonj',
         'Sylhet'=>'Tangail',
        
    
    
    
                );
echo form_dropdown('title', $dd_list);   ?&gt;

</td></tr>
  <tr >
<td width="150"><span class="ip_text">Phone</span><font color="red">&nbsp;*</font></td>
<td class="ip_text" valign="top">
    &lt;?php echo form_input(array('id'=>'phone','name' =>'phone','value' =>'type phone no'));?&gt;
</td>
  </tr>
      <tr >
<td width="150"><span class="ip_text">Fax</span></td>
<td class="ip_text" valign="top">
    &lt;?php echo form_input(array('id'=>'fax','name' =>'fax','value' =>'type fax no.'));?&gt;
</td>
      </tr>
    
  <tr >
<td width="150"><span class="ip_text">Email</span></td>
<td class="ip_text" valign="top">
    &lt;?php echo form_input(array('id'=>'email','name' =>'email','value' =>'type email address'));?&gt;
  </td></tr>
  <tr >
<td width="150"><span class="ip_text">Site Url</span></td>
<td class="ip_text" valign="top">
    &lt;?php echo form_input(array('id'=>'site_url','name' =>'site_url','value' =>'type your sile url'));?&gt;
    </td>
  </tr>

<tr>
<td>
</td>
<td>
&lt;?php echo form_submit(array('id'=>'submit','name'=>'submit'),"Submit"); ?&gt;
</td>
</tr>
</tbody>
&lt;?php echo form_close(); ?&gt;
</table>

controller.php
Code:
&lt;?php
    class Submit extends Controller{
            function Submit(){
                    parent::Controller();
            }
            function index(){
                    $this->load->view('submit_form');
            }
            function insert(){
                
$config['upload_path'] = base_url() . 'images/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);

  if ( ! $this->upload->do_upload())
  {
   $error = array('error' => $this->upload->display_errors());

   echo $error;
  }

                

            
              
}
            
          
              
            }
            
  


?&gt;







Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.