Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset ($_POST['upload'])){
- $allowed_ext = array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'rar', 'zip');
- $file_name = $_FILES['file']['name'];
- //$name_parts = explode('.', $file_name);
- $file_ext= strtolower(end($name_parts));
- $file_ext = strtolower(end(explode('.', $file_name)));
- $file_size = $_FILES['file']['size'];
- $file_tmp = $_FILES['file']['tmp_name'];
- $nama =$_FILES ['file']['name'];
- $tgl = date("Y-m-d");
- if(in_array($file_ext, $allowed_ext) === true){
- if($file_size < 1044070){
- $lokasi = 'files/'.$nama.'.'.$file_ext;
- move_uploaded_file($file_tmp, $lokasi);
- $cone = mysqli_connect('localhost','root','','gis');
- $in = mysqli_query($cone, "INSERT INTO tb_tempat VALUES(NULL, '$tgl', '$nama', '$file_ext', '$file_size', '$lokasi')");
- if($in){
- echo '<div class="ok">SUCCESS: File berhasil di Upload!</div>';
- }else{
- echo '<div class="error">ERROR: Gagal upload file!</div>';
- }
- }else{
- echo '<div class="error">ERROR: Besar ukuran file (file size) maksimal 1 Mb!</div>';
- }
- }else{
- echo '<div class="error">ERROR: Ekstensi file tidak di izinkan!</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement