Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Simple Crud</title>
  5. </head>
  6. <body>
  7. <h2>Simple CRUD</h2>
  8.  
  9. <a href="downloads.php">List Bekas Guru</a>
  10. / <a href="downloads1.php">List Bekas Siswa</a>
  11.  
  12. <h3>Upload File Guru</h3>
  13. <h2>Upload</h2>
  14. <p>Upload file anda melengkapi form di bawah ini. File yang bisa di Upload hanya file dengan ekstensi <b>.doc, .docx, .xls, .ppt, .pptx, .pdf, .rar, .zip</b> dan besar file (file size) maksimal hanya 1 MB.</p>
  15.  
  16. <?php
  17. error_reporting(0);
  18. include('config.php');
  19. if($_POST['uploads']){
  20. $allowed_ext = array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'rar', 'zip');
  21. $file_name = $_FILES['file']['name'];
  22. $file_ext = strtolower(end(explode('.', $file_name)));
  23. $file_size = $_FILES['file']['size'];
  24. $file_tmp = $_FILES['file']['tmp_name'];
  25.  
  26. $file_name = $_POST['nama'];
  27. $tgl = date("Y-m-d");
  28.  
  29. if(in_array($file_ext , $allowed_ext) == true){
  30. if($file_size < 1044070){
  31. $lokasi = 'files/'.$file_name.'.'.$file_ext;
  32. move_uploaded_file($file_tmp, $lokasi);
  33. $in = mysql_query("INSERT INTO download VALUES(NULL, '$tgl', '$file_name', '$file_ext', '$file_size', '$lokasi')");
  34. if($in){
  35. echo '<div class="ok">SUCCESS: File berhasil di Upload</div>' ;
  36. }else{
  37. echo '<div class="error">ERROR: Gagal upload file!</div>' ;
  38. }
  39. }else{
  40. echo '<div class="error">ERROR: Besar ukuran file(file size) maksimal 1 MB!</div>' ;
  41. }
  42. }else{
  43. echo '<div class="error">ERROR: Ekstensi file tidak di izinkan</div>' ;
  44. }
  45. }
  46. ?>
  47.  
  48. <p>
  49. <form action="" method="post" enctype="multipart/form-data">
  50. <table width="100%" align="center" border="0" bgcolor="#eee" cellpadding="2" cellspacing="0">
  51. <tr>
  52. <td width="40%" align="right"><b>Nama File</b></td>
  53. <td><b>:</b></td>
  54. <td><input type="text" name="nama" size="40" required /></td>
  55. </tr>
  56. <tr>
  57. <td width="40%" align="right"><b>Pilih File</b></td>
  58. <td><b>:</b></td>
  59. <td><input type="file" name="file" required /></td>
  60. </tr>
  61. <tr>
  62. <td>&nbsp;</td>
  63. <td>&nbsp;</td>
  64. <td><input type="submit" name="uploads" value="Upload" /></td>
  65. </tr>
  66. </table>
  67. </form>
  68. </p>
  69.  
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement