[php] action

Viewer

  1.  $ekstensi_simpan = array('pdf');
  2.                 $nama = $_FILES['lembar_ijazah']['name']; //nama file
  3.                 $x = explode('.', $nama);
  4.                 $ekstensi_kirim = strtolower(end($x));
  5.                 $ukuran = $_FILES['lembar_ijazah']['size'];//ukuran file
  6.                 $file_tmp = $_FILES['lembar_ijazah']['tmp_name'];//tempat
  7.  
  8.                 session_start();
  9.                 $_SESSION['refresh'] = true;
  10.                 $_SESSION['no_seri'] = htmlspecialchars($_POST['no_seri']);
  11.                 $_SESSION['nisn'] = htmlspecialchars($_POST['nisn']);
  12.                 $_SESSION['tgl_terbit'] = htmlspecialchars($_POST['tgl_terbit']);
  13.                 $_SESSION['no_sekolah'] = htmlspecialchars($_POST['no_sekolah']);
  14.                 $_SESSION['kd_jenjang'] = htmlspecialchars($_POST['kd_jenjang']);
  15.  
  16.                 if (in_array($ekstensi_kirim, $ekstensi_simpan) === true) {
  17.                     if($ukuran < 4044070 ) {
  18.                         $newNameFile = uniqid();
  19.                         $newNameFile .= '.';
  20.                         $newNameFile .= $ekstensi_kirim;
  21.                     
  22.                         $data = [
  23.                           'no_seri' => $_SESSION['no_seri'],
  24.                           'kd_jenjang' => $_SESSION['kd_jenjang'],
  25.                           'no_sekolah'  => $_SESSION['no_sekolah'],
  26.                           'nisn' => $_SESSION['nisn'],
  27.                           'tgl_terbit' => $_SESSION['tgl_terbit'],
  28.                           'lembar_ijazah' => $newNameFile
  29.                         ];
  30.                       
  31.                         move_uploaded_file($file_tmp, 'file/'.$newNameFile);
  32.                       
  33.                         $db->insert("ijazah",$data);
  34.                         $log = $db->tampil_edit('sekolah','no_sekolah',$_SESSION['no_sekolah']);
  35.                         $no = $db->tampil_edit('ijazah','no_seri',$_SESSION['no_seri']);
  36.  
  37.                         echo "<script>
  38.                           alert('Data berhasil Ditambahkan!');
  39.                           window.location.href = 'tampil_data_ijazah.php?no_sekolah=".$_SESSION['no_sekolah']."';
  40.                         </script>";
  41.                         session_destroy();
  42.  
  43.                     } else {
  44.                         echo "<script>
  45.                         alert('File terlalu besar!');
  46.                         history.back(self);
  47.                         </script>";
  48.                     }
  49.                 } else {
  50.                     echo "<script>
  51.                         alert('File yang anda upload bukan .pdf!');
  52.                         history.back(self);
  53.                         </script>";
  54.                 }

Editor

You can edit this paste and save as new:


File Description
  • action
  • Paste Code
  • 15 Jun-2021
  • 2.65 Kb
You can Share it: