php - Codeigniter Multiple File Upload Encryption Issue -


i've got big form allows users upload multiple files/filetypes offer/bid creating. working fine except 1 piece: name encryption of files before saving database.

i haven't found rhyme or reason it, it's hit or miss. image works fine every time. other documents (which allow [*] types, consist of various business docs such pdf, doc, xls, etc.) ones spotty.

i found threads on , elsewhere general issues name encryption have yet come across 1 deals specificity of issue.

here's upload function:

//for multi uploads         function do_uploads($name, $file)         {             $status ="";             $msg = "";             $file_element_name = $name;               //go through , figure out goes             if($name == "quotedoc") {                 $folder = "quotedocs";                 $allowed = '*';             }             else if($name == "productofferphoto") {                 $folder = "product_photos";                 $allowed = 'jpeg|jpg|png|gif';             }             else if($name == "researchwhtpaper1" || $name == "researchwhtpaper2") {                 $folder = "research";                 $allowed = "*";             }             else if($name == "productliterature1" || $name == "productliterature2") {                 $folder = "literature";                 $allowed = "*";             }             else if ($name == "fdalink") {                 $folder = "fda";                 $allowed = "*";             }               $config['upload_path'] = './uploads/' . $folder;             $config['allowed_types'] = $allowed;             $config['max_size']  = 1024 * 8;             $config['encrypt_name'] = true;              $this->load->library('upload', $config);              if ( ! $this->upload->do_upload($name))             {                 $status = 'error';                 $msg = $this->upload->display_errors('', '');             }             else {                 $data = $this->upload->data();             }              @unlink($_files[$file_element_name]);              //what's up?             //return $this->upload->data();             return array('status' => $status, 'msg' => $msg, 'data' => $this->upload->data(), 'allowed'=>$allowed);         } 

any appreciated.

you're not stating question clearly:

are names not being encrypted, still uploading correct directories?

are setting these inside loop, perhaps class instance not being re-initialized? first file encrypt correctly, not subsequent ones?

can track file types not working correctly?

i have trouble believing "random", , think there's not enough research being done here


solution below:

you need use $this->upload->initialize($config) change config, library loaded once


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -