1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72:
<?php
class UploadedFile
{
private $name = '';
private $mime_type = '';
private $size = 0;
private $tmp_name = '';
public function __construct($name, $mime_type, $size, $tmp_name)
{
$this->name = $name;
$this->mime_type = $mime_type;
$this->size = $size;
$this->tmp_name = $tmp_name;
}
public function get_name()
{
return $this->name;
}
public function get_name_without_extension()
{
$name = $this->get_name();
return TextHelper::substr($name, 0, TextHelper::strpos($name, '.'));
}
public function get_extension()
{
$filename = $this->get_name();
return TextHelper::strtolower(TextHelper::substr(TextHelper::strrchr($filename, '.'), 1));
}
public function get_mime_type()
{
return $this->mime_type;
}
public function get_size()
{
return $this->size;
}
public function get_temporary_filename()
{
return $this->tmp_name;
}
public function save(File $destination)
{
move_uploaded_file($this->tmp_name, $destination->get_path());
}
}
?>