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)
#1

[eluser]mad82[/eluser]
Code:
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*/  
<html>  
<head>  
<title>Upload Form</title>  
</head>  
<body>    

<?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;  

&lt;/form&gt;  

&lt;/body&gt;  
&lt;/html&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()  
{  
    parent::_construct();  
    $this->load->helper(array('form','url','file'));  
}  
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  
                                                       configuration*/    
    $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);  
    }  
    else  
    {  
        $data = array('upload_data' => $this->upload->data());  

        $this->load->view('upload_success', $data);  
    }  
}  
   }  
?&gt;
#2

[eluser]LuckyFella73[/eluser]
You can't have 2 classes with the same name name at the same time. Rename your controller class and try again.
#3

[eluser]mad82[/eluser]
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