Is it a good idea to overwrite Super Global Variables ?? |
In my opinion, we should discourage, happy to understand what best practice should be ?
Example, where $_FILES is overwritten as PHP Code: $filesCount = count($_FILES['files']['name']); This is commonly used code to upload multiple files .. If this is bad approach.. please share working code for multiple file upload without modify super globals.
There must be a lot of github projects with codeigniter and multiple file uploads.
Personally, I've never needed a multiple file upload.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
(09-14-2018, 11:18 AM)oppachoriya Wrote: In my opinion, we should discourage, happy to understand what best practice should be ? $upload_dir ='upload/'; if(isset($_FILES["sticker_image"]["name"]) && $_FILES["sticker_image"]["name"]!="") { $config['upload_path'] = $upload_dir; $config['allowed_types'] = 'png'; $file = time().'_'.str_replace(' ','_',$_FILES["sticker_image"]['name']); $insert["sticker_image"] = $file; $config['file_name'] = $file; $this->load->library('upload', $config); $this->upload->initialize($config); $this->upload->do_upload('sticker_image'); } Try this code.
Here is a tutorial on it that shows how to do it without all that mess.
Codeigniter Multiple Files Upload What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |