Welcome Guest, Not a member yet? Register   Sign In
how to upload text & photo together using codeigniter in a form
#1

[eluser]Ignis Avis[/eluser]
I am using codeigneter.I am having problem to upload multiple texts & pictures together. When I write the code for only uploading pictures it works nicely. But when I want to upload pictures & texts together, it just uploads the texts but not the pictures. & It even doesn't show any errors.

Code:
function do_upload()  
{
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size']   = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';
  $this->upload->initialize($config);
  $this->load->library('upload', $config);
  if ( ! $this->upload->do_upload())
  {
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('upload_form', $error);
  }
  else
  {
    $data = array('upload_data' => $this->upload->data());
    $this->load->view('upload_success', $data);
  }        
}

And in view file

Code:
<?php echo form_open_multipart('report/do_upload');?>
<input type="file" name="userfile" size="20" />

What I am doing wrong?
#2

[eluser]LuckyFella73[/eluser]
Code:
But when I want to upload pictures & texts together, it just uploads the texts but not the pictures.

What do you mean by "uploading texts"? Input fields/ textareas or text-files?
If you post the code containing the text-input and maybe the form validation part
we could try to find the issue. You just posted the code that seems to work.
#3

[eluser]Ignis Avis[/eluser]
Quote:What do you mean by “uploading texts”? Input fields/ textareas or text-files?
If you post the code containing the text-input and maybe the form validation part
we could try to find the issue. You just posted the code that seems to work.

Thanks for your reply. I mean input fields by “uploading texts”. Thanks.
#4

[eluser]LuckyFella73[/eluser]
ok - but you have to post all the relevant code if you want
other people to find the error. View file (at least the form part),
controller (all relevant methods including the part where your
input fields are validated/ processed).
In your post we can only see the file-upload part of your controller.




Theme © iAndrew 2016 - Forum software by © MyBB