[eluser]Manjunath Reddy[/eluser]
Dear All,
I am facing problem with uploading image.
CodeIgniter Version = 2.0.2,
I load the Upload library and my upload form code does not even call the Upload method do_upload.
here is my source code.
Code:
<?php
class Uploadtest extends CI_Controller{
var $upload_path;
public function __construct(){
parent::__construct();
}
function index(){
$this->upload_path = realpath(APPPATH . '../upload');
if($this->input->post('upload')){
echo "Working.....";
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->upload_path ,
'max_size' => 2000
);
$this->load->library('upload', $config);
$this->upload->do_upload();
//[b]Here it does not even call the do_upload() method[/b]
$image_data = $this->upload->data();
print_r($config);
echo "<br>";
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->upload_path.'/thumbs',
'maintain_ration' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
print_r($config);
}
$this->load->view('admin/uploadtest');
}
}
?>
My View
Code:
<form name="form1" action="uploadtest" method="post" enctype="multipart/form-data">
<?php
echo form_upload('userfile');
?>
<input type="submit" name="upload" value="Upload">
</form>
Here is the debug code I have included in the system/Upload.php
Code:
public function do_upload($field = 'userfile')
{
echo "inside do upload";
exit;
// Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_no_file_selected');
return FALSE;
}
in the above case, if input file name is not "userfile", does it work?...
If Im not wrong, why they force to use "userfile" as name in <input type='file' name='userfile'>
what If I have to give different name?
:-) is there an example for CI V2.0.2, I could follow up.
Is there something wrong with CI 2.0.2, Uploading API