Welcome Guest, Not a member yet? Register   Sign In
uploading two files, need to set different file type for each
#1

[eluser]Brad K Morse[/eluser]
I have two fields: image, document

I want to set allowed_types for each field, so image only accepts: jpg|png and document accepts: doc|xls|pdf

I know how to upload both those files from those fields, but I am unsure on how I would set each allowed_types, max_size, etc...

I checked the documentation, but it was not clear.

I assume I will need to create two different config arrays, example: $config_image[], $config_document[]

Then set it like this: $this->load->library('upload', $config_image) and $this->load->library('upload', $config_document)

Then set the appropriate field in $this->upload->do_upload("image")

So in theory:

Code:
$image = $this->input->post("image");
$document = $this->input->post("document");

if(!empty($image)) {
  // config_image stuff

  // do_upload for image field
}

if(!empty($document)) {
  // config_docucment stuff

  // do_upload for document field
}

I have not tried this, I wanted to see what you thought first, thanks.


Messages In This Thread
uploading two files, need to set different file type for each - by El Forum - 09-09-2012, 07:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB