Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-type: text/plain');
- /*
- ======================================================================
- MEGA drop. -File Hosting Platform
- Copyright (c) 2014 Anas Mazouni - Stormix. All rights reserved.
- ----------------------------------------------------------------------
- http://www.stormix.co/
- http://www.facebook.com/stormiix
- ======================================================================
- */
- // Include Config File
- include_once('includes/config.inc.php');
- // Include Functions File
- include_once('includes/func.inc.php');
- // Include Connection File
- include_once('includes/connect.inc.php');
- //Define a variable holding a temporary username
- $username = $_SESSION['user'] ;
- $allowed_files = $CONF['allowed_files'];
- //Upload file
- if (!empty($_FILES)) {
- /* Define variables */
- $file = $_FILES['file'];
- //Convert the file size to byte
- $max_size = ($CONF['max_file_size']*1024)*1024;
- //Get File name
- $ds = DIRECTORY_SEPARATOR;
- $filename = $file['name'];
- $tempfile = $file['tmp_name'];
- $targetPath = dirname( __FILE__ ) . $ds. "drop" . $ds;
- $target = $targetPath.time()."_".$filename;
- //Check if $_FILES variable is now empty
- if (!empty($_FILES)) {
- //Check if file type is allowed
- if($allowed_files == "All" OR in_array($file['type'],$allowed_files) OR in_array("All",$allowed_files)){
- //Check if any error occurred
- if($file['error'] == "0"){
- //Check if file is smaller than file size
- if($file['size'] <= $max_size){
- //Check if file is uploaded
- if(move_uploaded_file($tempfile,$target)){
- /*------------------------------------------------------------------------------------------------------------ */
- //Mysql commands
- $filename = $mysqli->real_escape_string($file['name']) ;
- $count = substr_count($filename, '.');
- $ext = explode('.',$filename);
- $type = $mysqli->real_escape_string(strtoupper($ext[$count])." File");
- $uploader =$mysqli->real_escape_string($_SESSION['user']);
- $key = substr(md5(rand(0,99999999)),0,8);
- $timestamp = time();
- $date = date('Y-m-d H:i:s');
- $size = bytesToSize($file['size']);
- $target = $mysqli->real_escape_string($target);
- //Insert query here
- /* ------------------------------------------------------------------------------------------------------------ */
- }else{$msg = "An error occurred while uploading."; exit($msg);}
- }else{$msg = "File is too big !</b>"; exit($msg);}
- }else{$msg = "An error occurred while uploading. <br>Error Code :".$file['error'] .""; exit($msg);}
- }else{$msg = "Invalid File Type"; exit($msg);}
- }else{$msg = "No files were selected"; exit($msg);}
- }else{header("location: index");}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement