-1

In Codeigniter syntax for normal PHP code $_POST['name'] is $this->input->post('name'). Does anyone knows what is syntax in CI for $_FILES['file']?

I don't want to upload, I want to catch file and make some action before uploading. In upload helper is only this: $this->upload->do_upload('file') - and that is uploading. I want to manage file before this step.

Thanks in advance

5
  • CI has its own File Uploading Class, you should Google that. Commented Jun 8, 2016 at 16:18
  • Yes it has, but even google can't help me with answer on this question. I need some experience CI user. Commented Jun 8, 2016 at 16:19
  • 1
    Here, I did it "for you" codeigniter.com/userguide3/libraries/… Commented Jun 8, 2016 at 16:19
  • 1
    possible duplicate of How to upload image in CodeIgniter? Commented Jun 8, 2016 at 16:20
  • No you didn't and isn't duplicate. I know how to upload ($this->upload->do_upload('userfile')), but I don't want to do that. I want to catch file, same as I can in PHP $_FILES['file'], but I want to do that in CI way. Commented Jun 8, 2016 at 16:23

1 Answer 1

0

You can call $_FILES directly before uploading

$this->load->library('upload', $config);//Load upload library class
foreach ($_FILES as $key => $value) {
 //manage the file $key and then upload it
 this->upload->do_upload($key);
}
Sign up to request clarification or add additional context in comments.

5 Comments

But I don't want to use $_FILES, I want to use for that CI syntax if exist?
In the previous comment which you deleted, you said you are going to check. Whether you checked it? is it working or not?
Yes, but I read answer again and I saw $_FILES, and that is exactly I want to avoid in code. Is it possible to write code in CI without $_FILES and somehow catch file? If is possible then great, otherwise thanks for effort, I will use $_FILES, what to do.
If you check the Upload.php library file, they also used $_FILES. So there is nothing wrong in using it.
I saw, and I will use $_FILES. I didn't manage to find another solution. This can't be locked. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.