SHARE
TWEET

uploadmp3fail

a guest Oct 12th, 2017 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include_once 'dbconfig.php';
  3. if(isset($_POST['btn-upload']))
  4. {    
  5.      
  6.     $file = rand(1000,100000)."-".$_FILES['file']['name'];
  7.     $file_loc = $_FILES['file']['tmp_name'];
  8.     $file_size = $_FILES['file']['size'];
  9.     $file_type = $_FILES['file']['type'];
  10.     $folder="uploads/";
  11.    
  12.     // new file size in KB
  13.     $new_size = $file_size/1024;  
  14.     // new file size in KB
  15.    
  16.     // make file name in lower case
  17.     $new_file_name = strtolower($file);
  18.     // make file name in lower case
  19.    
  20.     $final_file=str_replace(' ','-',$new_file_name);
  21.    
  22.     if(move_uploaded_file($file_loc,$folder.$final_file))
  23.     {
  24.         $sql="INSERT INTO tbl_uploads(file,type,size) VALUES('$final_file','$file_type','$new_size')";
  25.         mysql_query($sql);
  26.         ?>
  27.         <script>
  28.         alert('successfully uploaded');
  29.         window.location.href='up.php?success';
  30.         </script>
  31.         <?php
  32.     }
  33.     else
  34.     {
  35.         ?>
  36.         <script>
  37.         alert('error while uploading file');
  38.         window.location.href='up.php?fail';
  39.         </script>
  40.         <?php
  41.     }
  42. }
  43. ?>
RAW Paste Data
Top