CodeIgniter Forums
uploading - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: uploading (/showthread.php?tid=36170)



uploading - El Forum - 11-23-2010

[eluser]diasansley[/eluser]
i have tried the upload example from the wesite http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html

when i run the code and say upload i get the foll

the link is
http://localhost/CodeIgniter/search/upload/do_upload

and a 404 error.


Any help would be appreciated.
Thanks


uploading - El Forum - 11-23-2010

[eluser]InsiteFX[/eluser]
Use Post Reply and code tags and show your code!

InsiteFX


uploading - El Forum - 11-23-2010

[eluser]anaxamaxan[/eluser]
If you're following the code in the user guide, your controller class should be Upload, and the method is do_upload. So, your form action value, i.e. the form open in your view should be
form_open_multipart('upload/do_upload');
http://localhost/CodeIgniter/upload/do_upload

Are you putting the Upload controller in a subdirectory, i.e. application/controllers/search/upload.php ? If so, be sure your form_open_multipart() matches that path.


uploading - El Forum - 11-23-2010

[eluser]diasansley[/eluser]
Here is the controller

Code:
<?php

class Upload extends Controller {
    
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    
    function index()
    {    
        $this->load->view('upload_form', array('error' => ' ' ));
    }

    function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $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());
            
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            $this->load->view('upload_success', $data);
        }
    }    
}
?>

the view

Code:
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;



uploading - El Forum - 11-24-2010

[eluser]diasansley[/eluser]
ok
i got it working...
now what if i want to show all the images as thumbnails or something...


Thanks