for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace nebula\request\file;
use nebula\request\file\File;
/**
* HTTP请求文件
*/
class UploadedFile extends File {
private $originalName;
private $mimeType;
private $error;
public function __construct(string $path, string $name, string $mimeType = null, int $error = null) {
$this->mimeType = $mimeType ?: 'application/octet-stream';
$this->error = $error ?: UPLOAD_ERR_OK;
$this->originalName = pathinfo($name, PATHINFO_FILENAME);
parent::__construct($path);
}
* Get the value of error
public function getError()
{
return $this->error;
* Set the value of error
*
* @return self
public function setError($error)
$this->error = $error;
return $this;
* Get the value of mimeType
public function getMimeType()
return $this->mimeType;
* Set the value of mimeType
public function setMimeType($mimeType)
$this->mimeType = $mimeType;
* 判断文件是否可用
* @return boolean
public function isValid()
return UPLOAD_ERR_OK === $this->error && is_uploaded_file($this->getPathname());