i want upload excel file folder , upload file name database, gives me blank page url "http://localhost/myweb.com/admin/upload?file=tes+upload.xlsx". "tes upload" file name. file didn't upload folder database. don't know i'm missing. set folder permission 777.
my form :
<form action="<?php echo site_url('admin/upload')?>" enctype="multipart/form-data"> <input type="file" name="file" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"> <input type="submit" class="btn btn-success" value="submit"> </form>
my controller :
function upload() { if (!empty($_files)) { $filename = $_files["file"]["name"]; $file_basename = substr($filename, 0, strripos($filename, '.')); $file_ext = substr($filename, strripos($filename, '.')); $tempfile = $_files['file']['tmp_name']; $data = "admin".uniqid().$file_ext; $targetpath = getcwd() . '/uploads/'; $targetfile = $targetpath . $data ; move_uploaded_file($tempfile, $targetfile); $file_path = fcpath.'/uploads/'; require_once apppath."/third_party/phpexcel.php"; require_once apppath . "/third_party/phpexcel/iofactory.php"; $inputfilename = $file_path; $objphpexcel = phpexcel_iofactory::load($inputfilename); $alldatainsheet = $objphpexcel->getactivesheet()->toarray(null,true,true,true); $arraycount = count($alldatainsheet); // here total count of row in excel sheet $regex = "~\d{5}~"; $dataexcel = array(); for($i=1;$i<=count($dataexcel);$i++) { $dataexcel[$i]['to_name']=$alldatainsheet[$i]["a"]; $dataexcel[$i]['to_address']=$alldatainsheet[$i]["b"]; $dataexcel[$i]['to_phone']=$alldatainsheet[$i]["c"]; preg_match($regex, $alldatainsheet[$i]["b"], $result); $dataexcel['to_zipcode'] = $result[0]; }; $data_user = array( 'status' => '1', 'filename_admin' => $data, ); $this->load->model('excel'); $this->excel->upload_excel($alldatainsheet,$data_user); } }
my model :
function upload_excel($alldatainsheet) { $regex = "~\d{5}~"; array_shift($alldatainsheet); foreach ($alldatainsheet $key) { preg_match($regex, $key['b'], $result); $data = array( 'request_id' => $request_id, 'to_name' => $key['a'], 'to_phone' => $key['c'], 'to_address' => $key['b'], 'to_zipcode' => $result[0], 'tariff' => '0' ); $this->db->insert('excel', $data); $this->db->update('request',$request_id); } }
help me please. in advance