Advertisement
SashaRaaa

Untitled

Jul 18th, 2018
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Uploader {
  2.  
  3. public $field;
  4.  
  5. public function __construct ($field) {
  6.     $this->field = $field;
  7. }
  8.  
  9. public function isUploaded() {
  10.  
  11. return isset($_FILES [$this->field]) && (0 == $_FILES [$this->field]['error']);
  12.      }
  13.      
  14. public function upload() {
  15.     if ( $this->isUploaded() ) {
  16.     move_uploaded_file(
  17.     $_FILES [$this->field]['tmp_name'],
  18.     __DIR__ . '/images/uploaded.jpeg'
  19.     );
  20.    
  21.     }
  22. }
  23.  
  24. $image = new Uploader;
  25. $image->isUploaded();
  26. $image->upload();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement