views:

784

answers:

1

Hi there,

I'm creating a file upload in CodeIgniter, that uploads the file to the server and then stores some data in the database.

I have a form that asks for a file name and the file, which then uses my upload.php controller to upload the file to the server. Currently this part is working, I just need to insert the file name (entered from the form) into the table.

function do_upload()
{
 $config['upload_path'] = './gfiles/';
 $config['allowed_types'] = 'gif|jpg|jpeg|bmp|png|psd|pdf|eps|ai|zip|indd|qxt';
 $config['encrypt_name'] = 'TRUE';
 //$config['max_size'] = '100';

 $this->load->library('upload', $config);

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

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

  $this->db->insert('files', $_POST);

 }
}

Wondered if anyone has any pointers on how to get the file name (entered in the form) plus the actual filename and extension into the database? The code above also encrypts the filename.

Thank you.

A: 

$data = array('upload_data' => $this->upload->data()); should contain what you are looking for.

do print_r($data) and you should see the original and encrypted filename.

stef
Thanks @stef. It is outputting all of the values. There is also an Database Error; A Database Error Occurred, You must use the "set" method to update an entry.
Neil Bradley
The online manual really is top notch and easy to understand, don't forget to check it every now and then :)
stef