Guest User

Untitled

a guest
Dec 12th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. class Upload{
  4.  
  5. var $Allowed;
  6.  
  7. public function __construct($Directory,$Files,$FileExtensions = false,$Multiple = false,$MaxSize = 5120){
  8. $this->Allowed = ($FileExtensions) ? $Allowed = array_change_key_case(explode(",",$FileExtensions),CASE_UPPER) : false;
  9. }
  10.  
  11. public function ValidateExtension($FileName){
  12. $ExtensionSplit = explode(".",$FileName);
  13. $Extension = strtoupper(end($ExtensionSplit));
  14. return (in_array($Extension,$this->Allowed));
  15. }
  16.  
  17. public function UploadFile($File){
  18. if(move_uploaded_file($File['tmp_name'],'uploads/'.$File['name']))
  19. echo "Uploaded ".$File['name'];
  20. }
  21.  
  22. public function StartUploading(){
  23. foreach($_FILES as $File){
  24. if($this->ValidateExtension($File['name'])){
  25. $this->UploadFile($File);
  26. } else {
  27. echo "Invalid Extension for: ".$File['name'];
  28. }
  29. }
  30. }
  31.  
  32. }
  33. ?>
Add Comment
Please, Sign In to add comment