<?php
include 'cek.php';
$username = $_SESSION['username'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<tr>
<td><?php include('frame.php'); ?></td>
</tr>
<body bgcolor="black" TEXT="white">
<H1 align="center"><MARQUEE align="center" direction="left" height="70" scrollamount="3" width="100%"behavior="alternate"> ARSIP DIGITAL PT SINAR GALESONG PRATAMA </H1></MARQUEE></font>
<HR size=5 color="blue">
<TABLE>
<br>
<form method="post" enctype="multipart/form-data" action="upload.php">
<table>
<tr><td><input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<TR>
<br>
<TD> Keterangan : </TD>
<TD><INPUT TYPE="Text" NAME="keterangan" id="keterangan" SIZE="42"style="border-style: outset"></TD>
</TR>
</table>
<table>
<TR>
<br>
<TD> Bagian : </TD>
<TD><INPUT TYPE="Text" NAME="bagian" id="bagian" SIZE="20"style="border-style: outset"></TD>
</TR>
</table>
<br>
<table>
<TR>
<TD> Tanggal : </TD>
<TD><select name="tahun" onchange="showKab()"Tipe="text"name="tanggal" id="tahun" style="border-style: outset">
<OPTION> -Tahun- </OPTION>
<OPTION> 2011 </OPTION>
<OPTION> 2012 </OPTION>
<OPTION> 2013 </OPTION>
<OPTION> 2014 </OPTION>
<OPTION> 2015 </OPTION>
<OPTION> 2016 </OPTION>
<OPTION> 2017 </OPTION>
<OPTION> 2018 </OPTION>
<OPTION> 2019 </OPTION>
<OPTION> 2020 </OPTION>
<OPTION> 2021 </OPTION>
<OPTION> 2022 </OPTION>
<OPTION> 2023 </OPTION>
<OPTION> 2024 </OPTION>
<OPTION> 2025 </OPTION>
<OPTION> 2026 </OPTION>
<OPTION> 2027 </OPTION>
<OPTION> 2028 </OPTION>
<OPTION> 2029 </OPTION>
<OPTION> 2030 </OPTION>
<OPTION> 2031 </OPTION>
<OPTION> 2032 </OPTION>
<OPTION> 2033 </OPTION>
<OPTION> 2034 </OPTION>
<OPTION> 2035 </OPTION>
<OPTION> 2036 </OPTION>
<OPTION> 2037 </OPTION>
<OPTION> 2038 </OPTION>
<OPTION> 2039 </OPTION>
</td>
<TD>
<select name="bulan" onchange="showKab()"Tipe="text"name="tanggal" id="bulan" style="border-style: outset">
<OPTION> -Bulan- </OPTION>
<OPTION> 01 </OPTION>
<OPTION> 02 </OPTION>
<OPTION> 03 </OPTION>
<OPTION> 04 </OPTION>
<OPTION> 05 </OPTION>
<OPTION> 06 </OPTION>
<OPTION> 07 </OPTION>
<OPTION> 08 </OPTION>
<OPTION> 09 </OPTION>
<OPTION> 10 </OPTION>
<OPTION> 11 </OPTION>
<OPTION> 12 </OPTION></td>
<TD>
<select name="tanggal" onchange="showKab()"Tipe="text"name="tanggal" id="tanggal" style="border-style: outset">
<OPTION> -Tanggal- </OPTION>
<OPTION> 01 </OPTION>
<OPTION> 02 </OPTION>
<OPTION> 03 </OPTION>
<OPTION> 04 </OPTION>
<OPTION> 05 </OPTION>
<OPTION> 06 </OPTION>
<OPTION> 07 </OPTION>
<OPTION> 08 </OPTION>
<OPTION> 09 </OPTION>
<OPTION> 10 </OPTION>
<OPTION> 11 </OPTION>
<OPTION> 12 </OPTION>
<OPTION> 13 </OPTION>
<OPTION> 14 </OPTION>
<OPTION> 15 </OPTION>
<OPTION> 16 </OPTION>
<OPTION> 17 </OPTION>
<OPTION> 18 </OPTION>
<OPTION> 19 </OPTION>
<OPTION> 20 </OPTION>
<OPTION> 21 </OPTION>
<OPTION> 22 </OPTION>
<OPTION> 23 </OPTION>
<OPTION> 24 </OPTION>
<OPTION> 25 </OPTION>
<OPTION> 26 </OPTION>
<OPTION> 27 </OPTION>
<OPTION> 28 </OPTION>
<OPTION> 29 </OPTION>
<OPTION> 30 </OPTION>
<OPTION> 31 </OPTION></td>
</TR>
</table>
<br>
<br>
Upload File : <input name="userfile" type="file"> (Max: 2MB)
</td>
<p><td><input name="upload" type="submit" value="Upload">
</td>
</tr>
</table>
</form>
<br>
<br>
<td><?php include('footer.php'); ?></td>
</tr>
</html>
<?php
include 'cek.php';
$username = $_SESSION['username'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<tr>
<td><?php include('frame.php'); ?></td>
</tr>
<body bgcolor="black" TEXT="white">
<H1 align="center"><MARQUEE align="center" direction="left" height="70" scrollamount="3" width="100%"behavior="alternate"> ARSIP DIGITAL PT SINAR GALESONG PRATAMA</MARQUEE></h1>
<HR size=5 color="blue">
<TABLE>
<br>
<form method="post" enctype="multipart/form-data" action="upload.php">
<table>
<tr><td><input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<TR>
<br>
<TD> Keterangan : </TD>
<TD><INPUT TYPE="Text" NAME="keterangan" id="keterangan" SIZE="42"style="border-style: outset"></TD>
</TR>
</table>
<table>
<TR>
<br>
<TD> Bagian : </TD>
<TD><INPUT TYPE="Text" NAME="bagian" id="bagian" SIZE="20"style="border-style: outset"></TD>
</TR>
</table>
<br>
<table>
<TR>
<TD> Tanggal : </TD>
<TD><select name="tahun" onchange="showKab()" id="tahun" style="border-style: outset">
<OPTION> -Tahun- </OPTION>
<OPTION> 2011 </OPTION>
<OPTION> 2012 </OPTION>
<OPTION> 2013 </OPTION>
<OPTION> 2014 </OPTION>
<OPTION> 2015 </OPTION>
<OPTION> 2016 </OPTION>
<OPTION> 2017 </OPTION>
<OPTION> 2018 </OPTION>
<OPTION> 2019 </OPTION>
<OPTION> 2020 </OPTION>
<OPTION> 2021 </OPTION>
<OPTION> 2022 </OPTION>
<OPTION> 2023 </OPTION>
<OPTION> 2024 </OPTION>
<OPTION> 2025 </OPTION>
<OPTION> 2026 </OPTION>
<OPTION> 2027 </OPTION>
<OPTION> 2028 </OPTION>
<OPTION> 2029 </OPTION>
<OPTION> 2030 </OPTION>
<OPTION> 2031 </OPTION>
<OPTION> 2032 </OPTION>
<OPTION> 2033 </OPTION>
<OPTION> 2034 </OPTION>
<OPTION> 2035 </OPTION>
<OPTION> 2036 </OPTION>
<OPTION> 2037 </OPTION>
<OPTION> 2038 </OPTION>
<OPTION> 2039 </OPTION>
</td>
<TD>
<select name="bulan" onchange="showKab()"Tipe="text"name="tanggal" id="bulan" style="border-style: outset">
<OPTION> -Bulan- </OPTION>
<OPTION> 01 </OPTION>
<OPTION> 02 </OPTION>
<OPTION> 03 </OPTION>
<OPTION> 04 </OPTION>
<OPTION> 05 </OPTION>
<OPTION> 06 </OPTION>
<OPTION> 07 </OPTION>
<OPTION> 08 </OPTION>
<OPTION> 09 </OPTION>
<OPTION> 10 </OPTION>
<OPTION> 11 </OPTION>
<OPTION> 12 </OPTION></td>
<TD>
<select name="tanggal" onchange="showKab()"Tipe="text"name="tanggal" id="tanggal" style="border-style: outset">
<OPTION> -Tanggal- </OPTION>
<OPTION> 01 </OPTION>
<OPTION> 02 </OPTION>
<OPTION> 03 </OPTION>
<OPTION> 04 </OPTION>
<OPTION> 05 </OPTION>
<OPTION> 06 </OPTION>
<OPTION> 07 </OPTION>
<OPTION> 08 </OPTION>
<OPTION> 09 </OPTION>
<OPTION> 10 </OPTION>
<OPTION> 11 </OPTION>
<OPTION> 12 </OPTION>
<OPTION> 13 </OPTION>
<OPTION> 14 </OPTION>
<OPTION> 15 </OPTION>
<OPTION> 16 </OPTION>
<OPTION> 17 </OPTION>
<OPTION> 18 </OPTION>
<OPTION> 19 </OPTION>
<OPTION> 20 </OPTION>
<OPTION> 21 </OPTION>
<OPTION> 22 </OPTION>
<OPTION> 23 </OPTION>
<OPTION> 24 </OPTION>
<OPTION> 25 </OPTION>
<OPTION> 26 </OPTION>
<OPTION> 27 </OPTION>
<OPTION> 28 </OPTION>
<OPTION> 29 </OPTION>
<OPTION> 30 </OPTION>
<OPTION> 31 </OPTION></td>
</TR>
</table>
<br>
<br>
Upload File : <input name="userfile" type="file"> (Max: 2MB)
</td>
<p><td><input name="upload" type="submit" value="Upload">
</td>
</tr>
</table>
</form>
<br>
<br>
<td><?php include('footer.php'); ?></td>
</tr>
</html>
dan ini untuk file upload.php<?php
if(!$_POST){
echo('Tidak ada data yang harus disimpan!');
}else{
include 'cek.php';
// koneksi ke mysql
mysql_connect('localhost','root','admin');
mysql_select_db('dbname');
$keterangan = $_POST['keterangan'];
$bagian = $_POST['bagian'];
$tanggal = $_POST['tahun'].'-'.$_POST['bulan'].'-'.$_POST['tanggal'];
// membaca nama file
$fileName = $_FILES['userfile']['name'];
// membaca size file
$fileSize = $_FILES['userfile']['size'];
if(empty($keterangan) || empty($bagian) || empty($tanggal)){
echo '<strong>Data tidak komplit</strong>';
}elseif($fileSize < 0 || $_FILES['userfile']['error'] != 0){
echo 'Gagal upload file';
}elseif($fileSize / 1048576 > 2){ //1 megabytes = 1048576 bytes
echo 'Ukuran file melebihi 2MB';
}elseif(mysql_num_rows(mysql_query("select * from upload where name='$fileName'")) > 0){
echo 'File sudah ada didatabase';
}else{
// membaca nama file temporary
$tmpName = $_FILES['userfile']['tmp_name'];
// membaca tipe file
$fileType = $_FILES['userfile']['type'];
// membaca username yang disimpan dalam session
// username ini sekaligus menyatakan informasi pemilik file
$username = $_SESSION['username'];
// langkah membaca isi file yang diupload
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
// query SQL untuk menyimpan file ke database disertai username pemiliknya
$query = "INSERT INTO upload (name, size, type, content, username, keterangan, bagian, tanggal)
VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$username', '$keterangan', '$bagian', '$tanggal')";
mysql_query($query);
// konfirmasi
echo "<p>File ".$fileName." telah terupload</p>";
}
}
?>
<?php
include 'cek.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Menampilkan Data</title></head>
<tr>
<td><?php include('frame.php'); ?></td>
</tr>
<body BGCOLOR="#90EE90" TEXT="purple"font size="10">
<?php
mysql_connect("localhost","root","admin");
mysql_select_db("dbname");
$username = $_SESSION['username'];
echo "<h2 align='center'> Daftar File Anda </h2>";
$warnaGenap = "#CCCCCC"; // warna abu-abu
$warnaGanjil = "#FFFFFF"; // warna putih
$warnaHeading = "#FF0000"; // warna merah untuk heading tabel
$query = "SELECT * FROM upload WHERE username = '$username'";
$hasil = mysql_query($query);
echo '<table border="1" cellpadding="3" cellspacing="4">';
echo "<tr bgcolor='".$warnaHeading."'>";
echo '<td align="center"><B>ID</B></td>';
echo "<td align='center'><B>Keterangan</B></td>";
echo "<td align='center'><B>Tanggal</B></td>";
echo "<td align='center'><B>Bagian</B></td>";
echo "<td align='center'><B>Data Arsip</B></td>";
echo '<td colspan="2" align="center"><B>Action</td></B>';
echo "</tr>";
$counter = 1;
$conn=mysql_connect("localhost", "root", "admin");
mysql_select_db("dbname");
$sql="select * from upload WHERE username = '$username'";
$hasil=mysql_query($sql);
while($data = mysql_fetch_array($hasil))
{
// cek apakah counternya ganjil atau genap
if ($counter % 2 == 0) $warna = $warnaGenap;
else $warna = $warnaGanjil;
echo "<tr bgcolor='".$warna."'>";
echo "<td align='center'><B>".$data['id']."</B></td>";
echo "<td>".$data['keterangan']."</td>";
echo "<td>".$data['tanggal']."</td>";
echo "<td>".$data['bagian']."</td>";
echo "<td>".$data['name']."</td>";
echo "<td>";
echo "<a href='edit_arsip.php?id=".$data['id']."'> Edit </a>";
echo "</tr>";
$counter++; // menambah counter
}
echo "</table>";
?>
<br>
<br>
<tr>
<td><?php include('footer.php'); ?></td>
</tr>