Guest User

Upload Image Issue In Server

a guest
May 26th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require('classes/autoloader.php');
  4. $flash = new \Library\FlashMessage();
  5. $common = new \Library\CommonFunction();
  6. $check_document = new \Model\CheckDocumentModel();
  7. if (isset($_POST['add_chk_doc'])) {
  8.  
  9.     $filecontent = $_FILES['chk_doc_image']['name'];
  10.     $dividefile = explode(".", $filecontent);
  11.     $totaldivdedcontent = (sizeof($dividefile) - 1);
  12.     $extension = $dividefile[$totaldivdedcontent];
  13.     if ($_FILES['chk_doc_image']['size'] == "0") {
  14.  
  15.         $flash->setMessage(array(
  16.             "type" => "danger",
  17.             "message" => "Seems you have not selected any file. Please try again"
  18.         ));
  19.         $common->redirect_to_page(BASE_PATH . 'check_document_add.php');
  20.  
  21.     }
  22.     elseif ($extension != 'jpg' && $extension != 'jpeg' && $extension != 'png') {
  23.  
  24.         $flash->setMessage(array(
  25.             "type" => "danger",
  26.             "message" => "Imported file in Invalid. Please check if the uploaded file is Image."
  27.         ));
  28.         $common->redirect_to_page(BASE_PATH . 'check_document.php');
  29.  
  30.     }
  31.     else {
  32.  
  33.         $uniqid = date("YmdHis");
  34.         $newfilename = $uniqid . "_chk_doc." . $extension;
  35.         $upload_path = "upload/" . $newfilename;
  36.         $move = move_uploaded_file($_FILES['chk_doc_image']['tmp_name'], $upload_path);
  37.  
  38.     }
  39.     $ca_code = 'LAN-CDOC' . '-' . rand(0, 9999);
  40.     $doc_check = implode(",",$_POST["chk_status"]);
  41.  
  42.     $parameter = array(
  43.         "chk_doc_code" => $ca_code,
  44.         "batch_code" => $_POST['batch_no'],
  45.         "student_code" => $_POST['student_no'],
  46.         "doc_name" =>$_POST['doc_name'],
  47.         "chk_status"=>$doc_check,
  48.         "chk_by" =>$_POST['chk_by'],
  49.         "status" => $_POST['status'],
  50.         "chk_doc_image" =>$newfilename
  51.     );
  52.  
  53.     $result = $check_document->checkDocumentAdd($parameter);
  54.     if ($result) {
  55.         $flash->setMessage(array(
  56.             "type" => "success",
  57.             "message" => "Check Document Successfully Completed"
  58.         ));
  59.     } else {
  60.         $flash->setMessage(array(
  61.             "type" => "danger",
  62.             "message" => "Check Document Failed!!!"
  63.         ));
  64.  
  65.     }
  66.     $common->redirect_to_page(BASE_PATH . 'check_document.php');
  67.  
  68. } else {
  69.     $flash->setMessage(array(
  70.         "type" => "danger",
  71.         "message" => "Check Document Data Failed!!!"
  72.     ));
  73.     $common->redirect_to_page(BASE_PATH . 'check_document.php');
  74. }
Add Comment
Please, Sign In to add comment