<?php
ob_start();
session_start();
ob_end_clean();
if(isset($_SESSION["username"])){
echo "Upload File";
}else{
echo header("location:index.php");
}?>
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type']; $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("jpeg","jpg","png","gif","docx","doc","xls","txt","zip","pptx","ppt","ppx","mp3","ico","php","xlsx");
if(in_array($file_ext,$expensions)===false){
$errors[]="extension not allowed, please choose a register extension file.";}
if($file_size >5097152){
$errors[]='File size must be excately 5 MB';}
if(empty($errors)==true){ move_uploaded_file($file_tmp,"file/".$file_name);
echo "Success";}else{ print_r($errors);}}?>
<html><body><form action="" method="POST" enctype="multipart/form-data"><input type="file"name="image"/><input type="submit"/><ul><li>Sent file: <?php echo $_FILES['image']['name'];?><li>File size: <?php echo $_FILES['image']['size'];?><li>File type: <?php echo $_FILES['image']['type']?></ul></form>
<a href='home_admin.php'> <Kembali</a>
</body></html>