CodeIgniter Forums
difficulty in uploading file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: difficulty in uploading file (/showthread.php?tid=42986)



difficulty in uploading file - El Forum - 06-25-2011

[eluser]adityajoshi[/eluser]
my view is some thing like this

form action="http://localhost/version-2/add/collect" method="post" id = "1" class="def-form">
<div class="section">
<div class="row">
<label class="main-label">What</label>
&lt;input type="text" name = "event" id="autocomplete" class="field" /&gt;
</div>
&lt;?php
echo form_open_multipart('gallery');
echo form_upload('userfile');
echo form_submit('upload', 'Upload');
echo form_close();
?&gt;
&lt;input type="submit" class="main-btn" value="Add Event" /&gt;
<div class="cl">&nbsp;</div>
&lt;/form&gt;

my controller is

&lt;?php
var_dump($_POST);
class Add extends Controller{
public function __construct() {
parent::Controller();
$this->load->helper(array('form','url'));
$this->load->library('form_validation');
}
function index() {
$this->load->view('add_form');
}
function collect()
{
echo("checkpoint0");
$this->load->model('Gallery_model');
if ($this->input->post('upload')) {
echo("checkpoint1");
$this->Gallery_model->do_upload();
}
$data['images'] = $this->Gallery_model->get_images();
$this->load->view('gallery', $data);
}

my model is

&lt;?php
var_dump($_POST);
class Gallery extends Controller {

function index() {

$this->load->model('Gallery_model');

if ($this->input->post('upload')) {
$this->Gallery_model->do_upload();
}

$data['images'] = $this->Gallery_model->get_images();

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

}

}

some how it doesn't work had spent two days but still struck any help will be highly appreciated


difficulty in uploading file - El Forum - 06-25-2011

[eluser]InsiteFX[/eluser]
If your using CodeIgniter 2.0.+ it is extends CI_Controller not Controller!

Model is CI_Model not Model!

InsiteFX


difficulty in uploading file - El Forum - 06-26-2011

[eluser]adityajoshi[/eluser]
Some how i made it work by debugging for four hours, but i have question how can i manage images.

My problem is getting image and information from user and posting it on other page with date stamped on image? what shall i use? shall i insert images in to db or into local folder
, i have images in local folder how can i extract in a way that it also tell what date it was posted on .


Any suggestion, snippet of code or related tutorial link will be highly appreciated