post/FileUpload.php

19 lines
422 B
PHP
Raw Permalink Normal View History

2019-08-14 19:22:54 +02:00
<?php
namespace Post;
class FileUpload extends FormField {
protected $file;
protected $error=UPLOAD_ERR_NO_FILE;
public function loadFromEnv($name) {
$this->error=$_FILES[$name]['error'];
$this->value=$_FILES[$name]['name'];
$this->file=$_FILES[$name]['tmp_name'];
}
2019-08-16 12:26:37 +02:00
public function getTmpPath() {
if ($this->error > 0) throw new UploadException("Upload failure", $this->error);
return $this->file;
}
2019-08-14 19:22:54 +02:00
}