Welcome Guest, Not a member yet? Register   Sign In
Upload and Database Question
#1

[eluser]the_unforgiven[/eluser]
Hi All,

I have a upload box in a form and everything is fine, but if i just update the textarea then save it, it removes the PDF i previously uploaded, i presume an IF statement will do this but what should I write Im not quite sure?

Here's my update function in my model:

Code:
function updateMemberpage()
{
     $data = array(
      'title' => $this->input->post('title'),
'body' =>  $this->input->post('body'),
'status' => $this->input->post('status')
      );

     $image_data = $this->upload->data();
     $data['file'] = $image_data['file_name']; // This is where i need it state if nothing is entered in the upload leave the previous file there until something new is uploaded.

     $this->db->where('status', 'Active');
     $this->db->update('memberpage', $data);
}
#2

[eluser]gRoberts[/eluser]
I usually check the $_FILES array before calling the CI Upload class, i.e.

Code:
if(isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0)
{
// upload file
// set $data['file'] = $image_data['file_name'];
}

this way, only if you actually upload something does it set the `$data['file']` value.
#3

[eluser]the_unforgiven[/eluser]
Swett just what i needed, thank a million i tried alsorts but that works a treat!!!




Theme © iAndrew 2016 - Forum software by © MyBB