[eluser]Gwarrior[/eluser]
As the title suggests, I am trying to create a script (for my backend CMS) that will 1) Upload a file and 2) Pull out the File Name so I can store it in the database, in order to retrieve it at a later time.
For some reason it just isn't working.
Here's the excerpt from my controller:
Code:
function work() {
// set upload params
$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);
// check to see if user is logged in
if ($this->session->userdata('logged_in') == TRUE) {
$data['logged_in'] = $this->session->userdata('logged_in');
$data['jobs'] = $this->db->query('SELECT * FROM jobs');
if (isset($_POST['submitted'])) {
// upload logo file then pull the filename out for db upload
$holder_1 = $this->input->post('logo');
$this->upload->do_upload($holder_1);
$ul_data_1 = $this->upload->data();
$qdata['logo'] = $ul_data_1['file_name'];
// upload navimg file then pull the filename out for db upload
$holder_2 = $this->input->post('navimage');
$this->upload->do_upload($holder_2);
$ul_data_2 = $this->upload->data();
$qdata['navimg'] = $ul_data_2['file_name'];
// upload the rest
$qdata['site'] = $this->input->post('sitename');
$qdata['link'] = $this->input->post('link');
$qdata['text'] = $this->input->post('text');
$qdata['programs'] = serialize($this->input->post('programs'));
// freeze out while testing - $qdata['images'] = serialize($this->input->post('images'));
$this->db->insert('jobs', $qdata);
}
$this->load->view('jobs', $data);
} else {
// if not logged in, redirect
redirect('login', 'refresh');
}
}
And here is my view:
Code:
<h2>New Completed Job</h2>
<form action="" enctype="multipart/form-data" method="post">
<h3>Site Name:</h3>
<input type="text" name="sitename" value="" />
<h3>Logo:</h3>
<input type="file" name="logo" value="" />
<h3>Link:</h3>
<input type="text" name="link" value="" />
<h3>Programs:</h3>
<input type="checkbox" name="programs[]" value="(X)HTML" />(X)HTML<br />
<input type="checkbox" name="programs[]" value="PHP" />PHP<br />
<input type="checkbox" name="programs[]" value="JavaScript" />JavaScript<br />
<input type="checkbox" name="programs[]" value="JQuery" />JQuery<br />
<input type="checkbox" name="programs[]" value="Photoshop" />Photoshop<br />
<input type="checkbox" name="programs[]" value="Illustrator" />Illustrator<br />
<input type="checkbox" name="programs[]" value="Dreamweaver" />Dreamweaver<br />
<input type="checkbox" name="programs[]" value="MySQL" />MySQL
<h3>Images:</h3>
<input type="file" name="images[]" value="" />
<h3>Nav Image:</h3>
<input type="file" name="navimage" value="" />
<h3>Text:</h3>
<textarea name="text" style="width: 400px; height: 200px; overflow: scroll;"></textarea>
<br />
<input type="submit" name="submitted" />
</form>
See anything I should change around to make this work (and yes, I know I should use a model for my DB functions)? Any help would be greatly appreciated!