Welcome Guest, Not a member yet? Register   Sign In
Newbie: if using a model to update a database, how do i add upload data
#1

[eluser]loopymonkey[/eluser]
I'm confused how this should be written using a model to add to my database:

Code:
function add_toMyDatabase()
  {
    $YourName = $this->input->post('YourName');
    $upload_data['file_name'] = $this->input->post('userfile');
    $this->db->query("INSERT INTO toMyDatabase (id, YourName, userfile) VALUES(NULL, '$YourName', '$userfile')");
  }

From a form i am uploading a person's name and the name of the file that i received. I know my $upload_data contains the information i need since i'm using the upload helper, I'm just not certain how i can get JUST the file_name and put it into my database's field called userfile.

Any leads or help appreciated!
#2

[eluser]loopymonkey[/eluser]
I think i just figured it out myself. I was just missing this in my model:

Code:
$upload_data = $this->upload->data();
$userfile =    $upload_data['file_name'];

just needed that upload_data line
#3

[eluser]blu3ness[/eluser]
side note: storing the file content directly into the database seems a bad idea to me :x. I'd rather let OS do the file handling and use the DB just to keep an index of it :O




Theme © iAndrew 2016 - Forum software by © MyBB