Guest User

Untitled

a guest
Dec 30th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2.  
  3. $uploadDir      = '';
  4. $maxFilesize    = 2000000;
  5. $extensions     = array('mp3');
  6.  
  7. $maxWidth       = 90000;
  8. $maxHight       = 80000;
  9.  
  10. $errors         = array();
  11. $fileCount      = (int) count(glob($uploadDir . "*.mp3"));
  12.  
  13. if (isset($_FILES['image'])) {
  14.    
  15.     // Get file information
  16.     $fileName = strtolower($_FILES['image']['name']);
  17.     $fileSize =$_FILES['image']['size'];
  18.     $fileTmp =$_FILES['image']['tmp_name'];
  19.     $fileType=$_FILES['image']['type'];  
  20.     $fileExtension =strtolower(end(explode('.',$_FILES['image']['name'])));
  21.     list($height, $width) = getimagesize($fileTmp);
  22.    
  23.     // Check for errors
  24.     if (!in_array($fileExtension, $extensions)) {
  25.         $errors[] = 'File is not an allowd file type.';
  26.     }
  27.     if ($fileSize > $maxFilesize) {
  28.         $errors[] = 'File exceed to maximum file size.';
  29.     }
  30.     if ($height > $maxHeight) {
  31.         $errors[] = 'File height is to large.';
  32.     }
  33.     if ($width > $maxWidth) {
  34.         $errors[] = 'File width is to large';
  35.     }
  36.    
  37.     // Error catcher
  38.     if (count($errors) > 0) {
  39.         foreach ($errors as $error) {
  40.             echo $error . '<br />';
  41.         }
  42.     } else {
  43.         move_uploaded_file($fileTmp, $uploadDir . '/song' . ($fileCount + 1) . '.mp3' );
  44.        
  45.         echo 'Song successfully uploaded';
  46.         echo '<br />Link To Song <input type="text" class="optionstxt" readonly style="width:300px;" value="http://'. $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['REQUEST_URI']), '\\/') . '/'. $uploadDir .'">';      
  47.     }
  48. } else {
  49.     'No image to upload.';
  50. }
Advertisement
Add Comment
Please, Sign In to add comment