Codeigniter file upload failing -


i have form allows file uploads. adds database fine, doesn't save file specified folder. view , model code below (my controller check see if file set proceeds upload)

view:

<form action="admin/admin_area/save_personnel" method="post" enctype="multipart/form-data" id="add_personnel">     <input type="file" name="offshore_medical_certificate" /> </form> 

controller:

function uploadoffshoremedical($uid) {        $status = "";     $msg = "";     $file_element_name = 'offshore_medical_certificate';     $certificate_name = 'offshore medical';     if ($status != "error")     {         $config['upload_path'] = './certificate_files/';         $config['allowed_types'] = 'pdf|doc|docx|txt|png|gif|jpg|jpeg|';         $config['max_size']  = 1024 * 8;         $config['encrypt_name'] = true;          $this->load->library('upload', $config);          if (!$this->upload->do_upload($file_element_name))         {             $status = 'error';             $msg = $this->upload->display_errors();         }         else         {             $data = $this->upload->data();             $file_id = $this->savecertificate($uid, $data['raw_name'], $data['file_ext'], $certificate_name);         }         if($file_id)         {             $status = "success";             $msg = "file uploaded";         }         else         {             unlink($data['full_path']);             $status = "error";             $msg = "something went wrong when saving file, please try again.";         }          @unlink($_files[$file_element_name]);     }        echo json_encode(array('status' => $status, 'msg' => $msg)); } 

i have correct file name form, file i'm uploading correct size , correct file extension. i'm working localhost folders permissions fine, reason isn't working. have done similar on project recently, can't seem find problem.

any appreciated.

edit:

if print $data following

array ( [file_name] => 08f8ce288e45207735bdb3f0c3139a0a.txt [file_type] => text/plain [file_path] => c:/wamp/www/marine/certificate_files/ [full_path] => c:/wamp/www/marine/files/08f8ce288e45207735bdb3f0c3139a0a.txt [raw_name] => 08f8ce288e45207735bdb3f0c3139a0a [orig_name] => license.txt [client_name] => license.txt [file_ext] => .txt [file_size] => 2.44 [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => )   {"status":"error","msg":"something went wrong when saving file, please try again."} 

i suggest use uploadify http://www.uploadify.com

it's easy use jquery plugin amazing documentation. started using since began coding , never had issues.

this way can resolve issues both projects.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -