Welcome Guest, Not a member yet? Register   Sign In
Multi-upload not working
#1

[eluser]RaZoR LeGaCy[/eluser]
can someone please look at my code and see where I am going wrong.

Controller:
Code:
$config['upload_path'] = './imgs/listings/'.$this->db->insert_id().'/';
$config['allowed_types'] = 'gif|jpg';
$config['overwrite']  = TRUE;
$config['max_size']    = '2048';
$config['max_width']  = '800';
$config['max_height']  = '600';
$config['remove_spaces']  = TRUE;

    
        $this->load->helper('file');

        $this->load->library('upload', $config);
        
        
mkdir($_SERVER['DOCUMENT_ROOT']."/imgs/listings/".$this->db->insert_id()."", 0777);

foreach($_FILES as $key => $value){
    if ( ! $this->upload->do_upload($key)){
        // do something here
} else {
$data = array($key => $this->upload->data());
}
}

View:
Code:
<table>
<tr>
    <td align="right" valign="top">Image #1:</td>
    <td colspan="2">&lt;input type="file" name="1" size="20" id="1" /&gt;</td>
    <td width="100" align="right">Image #2:</td>
    <td>&lt;input type="file" name="2" size="20" id="2" /&gt;</td>
</tr>
<tr>
  <td align="right" valign="top">Image #3:</td>
  <td colspan="2">&lt;input type="file" name="3" size="20" id="3" /&gt;</td>
  <td align="right">Image #4:</td>
  <td>&lt;input type="file" name="4" size="20" id="4" /&gt;</td>
</tr>
<tr>
  <td align="right" valign="top">Image #5:</td>
  <td colspan="2">&lt;input type="file" name="5" size="20" id="5" /&gt;</td>
  <td align="right">Image #6:</td>
  <td>&lt;input type="file" name="6" size="20" id="6" /&gt;</td>
</tr>
</table>

Thank you
#2

[eluser]abmcr[/eluser]
What is the problem? the error?.....
#3

[eluser]RaZoR LeGaCy[/eluser]
just not uploading, something I suspect is wrong with the path but I tried everything like ./imgs, document_root variable, /imgs, imgs

I used a regular upload script written in php and will post later.

I want it to be totally CI though since I digg the Framework

Any suggestions is welcome
#4

[eluser]xenon-dev[/eluser]
I am pretty sure it will work if you put that table into a form:

Code:
&lt;form action="..." method="post" enctype="multipart/form-data"&gt;
<your table>
</your table>
&lt;/form&gt;

Make sure not to miss that enctype part, or it won't work. The path is relative to the index.php file (./images would try to upload the file into the images/ directory, which MUST be in the same directory as the index.php file). I suggest you go with absolutes, but it's your choice.




Theme © iAndrew 2016 - Forum software by © MyBB