Skip to content

Instantly share code, notes, and snippets.

@novalagung
Created November 8, 2012 04:26
Show Gist options
  • Save novalagung/4036790 to your computer and use it in GitHub Desktop.
Save novalagung/4036790 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
html, body {
height: 100%;
width: 100%;
overflow: hidden;
}
.center-middle {
display: table;
height: 100%;
width: 100%;
}
.center-middle > div {
display: table-cell;
height: 100%;
width: 100%;
vertical-align: middle;
}
#main {
height: 500px;
width: 500px;
margin: 0px auto;
background-color: #FDFDFD;
}
textarea[name=file-content] {
width: 493px;
height: 300px;
}
</style>
</head>
<body>
<?php
$is_file_uploaded = false;
$file_target_name = '';
if (isset($_POST['submit']) && $_POST['submit'] == 'Read') {
$file_target_name = basename($_FILES['file-target']['name']);
if (move_uploaded_file($_FILES['file-target']['tmp_name'], $file_target_name)) {
$is_file_uploaded = true;
/**
* friska, tinggal masukin ke database,
* taruh aja koding nya di baris ini. tambahin sendiri ya
*/
}
}
?>
<div class="center-middle">
<div>
<div id="main">
<form enctype="multipart/form-data" method="post">
<div>
<label>Choose a file</label>
<input type="file" required name="file-target" />
<input type="submit" name="submit" value="Read" />
</div>
<div>
<textarea name="file-content">
<?php
if ($is_file_uploaded) {
$file_target_handler = fopen($file_target_name, "r");
while (!feof($file_target_handler)) {
echo fgets($file_target_handler);
}
fclose($file_target_handler);
}
?>
</textarea>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment