Source for file upload.php

Documentation is available at upload.php

  1. <?php
  2. // Uploadify v1.6.2
  3. // Copyright (C) 2009 by Ronnie Garcia
  4. // Co-developed by Travis Nickels
  5.  
  6. include('../../../../config.php');
  7.  
  8. if (!empty($_FILES)) {
  9.     $tempFile $_FILES['Filedata']['tmp_name'];
  10.     $targetPath $CFG->dataroot.'/'.SITEID.'/presenter/'.$_GET["moduleId"].'/';
  11.     $targetFile =  str_replace('//','/',$targetPathstr_replace(' ','_',$_FILES['Filedata']['name']);
  12.      
  13.     //Server side security check
  14.     //only allow images!!!
  15.     $allowable array ('.jpg','.gif','.png','.htm','html','.mov')
  16.     //get the extension of the file being uploaded              
  17.     $fileext strtolower(substr($targetFile-));
  18.     
  19.      // Assume evil upload 
  20.      $noMatch 0;
  21.      // Give it a try with this tiny extensionckeck    
  22.      foreach$allowable as $ext {
  23.       if strcasecmp$fileext$ext == {
  24.          $noMatch 1;
  25.       }
  26.      }   
  27.     if(!$noMatch)// an evil upload was attempted by an evil avatar!!!
  28.       echo "This file is not allowed...";
  29.       exit();
  30.     }
  31.    else //oh, its a good avatar uploading good files
  32.       mkdir(str_replace('//','/',$targetPath)0755true);
  33.       move_uploaded_file($tempFile,$targetFile);
  34.       echo "1";
  35.    }
  36. ?>

Documentation generated on Fri, 17 Jul 2009 11:02:35 +0100 by phpDocumentor 1.4.0