Welcome Guest, Not a member yet? Register   Sign In
[Solved] Problems uploading 2 images on one form.
#1

[eluser]mikka23[/eluser]
I have a form with two file inputs to upload images. My problem is uploading the second one. How do I upload two images and also retrieve the info for each upload separately (filename etc.)? All help is appreciated. At the moment only the first image is uploaded. The filepath for the first image is also shown where I expected the second file path to be.

In my controller:
Code:
$config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '10000';
        $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());
            
            $this->load->view('addpageerror', $error);
            
        }    
        else
        {    
$uploadimg = $this->upload->data('userfile');
                    $uploadthumb = $this->upload->data('thumbnail');
                    
                    $date = date("Y-m-d");
                    $this->ptitle = $_POST['ptitle'];
                    $this->pabout = $_POST['pabout'];
                    $this->fullscr = $uploadimg['full_path'];/// First image path
                    $this->thumbnail = $uploadthumb['full_path']; /// Second Image Path
                    $this->url = $_POST['url'];
                    $this->date = $date;
                    $this->db->insert('portfolio',$this);

$data = array('upload_data' => $this->upload->data());
}

Form:
Code:
<h2>Add New Work</h2>

&lt;?php echo  form_open_multipart('admin/portfolio/addwork'); ?&gt;
<h4>Project Title</h4>
&lt;input type="text" name="ptitle" value="" size="50" /&gt;
<h4>About Project</h4>
&lt;?
$data = array(
  'name'  => 'pabout',
  'id' => 'pabout',
  'value' => '',
  'rows' => '15',
  'cols'  => '80',
  'style' => 'width:100%',
   );

echo form_textarea($data);
?&gt;

<h4>Services Used</h4>
&lt;?php
        foreach($skillset->result() as $bow){
echo form_checkbox('skill[]', $bow->id, FALSE);
echo "$bow->value";
            }
         ?&gt;


<h4>URL of Demo</h4>
&lt;input name="url" value="http://" type="text" /&gt;

<h4>Full Screenshot of Design</h4>
<p>Dimensions - 1024x768</p>
<p>&lt;input name="userfile" type="file" /&gt;&lt;/p>


<h4>Small Thumbshot of Design</h4>
<p>Dimension - 174x103 </p>
<p>&lt;input name="thumbnail" type="file" /&gt;&lt;/p>

<p>&lt;input type="submit" value="Submit" /&gt;&lt;/p>

&lt;/form&gt;
#2

[eluser]mikka23[/eluser]
Just noticed the image manipulation class. Codeigniter is awesome!

EDIT NEW PROBLEM: Displayed in original post
#3

[eluser]mikka23[/eluser]
I encountered a new problem and instead of starting a new thread just changed the content in this one. Any help is greatly appreciated. I can't seem to work this one out :S




Theme © iAndrew 2016 - Forum software by © MyBB