Welcome Guest, Not a member yet? Register   Sign In
file uploading in codeIgniter (After selecting a file and click upload, being directed to XAMP home page)

hi im new to codeIgniter n have a problem while using the file upload script from user  
guide, upload form view is executing and displays the output, but after selecting a  
file and click on upload its being directed to XAMP home page as im using XAMP, [quote]Any  
help is greatly appreciated.[/quote]
/*this is view code I used upload_form.php code*/  
<title>Upload Form</title>  

<?php echo $error;?>  

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

<input type="file" name="file" />  

<br /><br />  

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



/*this is the controller class I used upload.php code*/  
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');  

class Upload extends CI_Controller  
function _construct()  
function index()  

    $this->load->view('upload_form', array('error' => ' ' ));  

function do_upload()  
    $config['upload_path'] = $_SERVER['DOCUMENT_ROOT']."uploads";  
    $config['allowed_types'] = 'gif|jpg|png';  
    $config['max_size']= '100';  
    $config['max_width']  = '1024';  
    $config['max_height']  = '768';  

    $this->load->library('upload', $config);/* load library file with specified  
    $field_name = "file"; /*variable passed to form*/  

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

        $this->load->view('upload_form', $error);  
        $data = array('upload_data' => $this->upload->data());  

        $this->load->view('upload_success', $data);  

You can't have 2 classes with the same name name at the same time. Rename your controller class and try again.

Quote:Hi, Thanks for ur reply, I've changed the controller class name and tried, didn't workout, still same problem, couldn't understand wat to do.

Theme © iAndrew 2016 - Forum software by © MyBB