Ja bym jeszcze sprawdzil:
<?php
/**
* Allowed file extensions
* @array
*/
public $allowed_extensions = array();
/**
* Allowed mime-types of uploaded files
* @array
*/
public $allowed_mime_types = array();
/**
* Get file extension
* @return string extension
*/
public function getExtension()
{
return $file['extension'];
}
/**
* Get MIME (uses FILEINFO extension, howerer, if it is not compiled, extracts the mime
type from a request constant)
* @return string Mime-Type
*/
public function getMimeType()
{
if (class_exists('finfo', false))
{
$finfo = new finfo(FILEINFO_MIME);
{
return $finfo->file($this->getTMPName());
}
else
{
return $finfo->file($this->upload_dir.$this->upload_file_name);
}
}
else
{
return isset($this->data[$this->upload_form_field]['type']) ?
$this->data[$this->upload_form_field]['type'] : null; }
}
/**
* Check if the mime-type of an uploaded file is allowed and throw an exception when it is not.
* @return Exception - if not allowed, bool true if allowed
*/
protected function checkMimeType()
{
if (!in_array($this->getMimeType(), $this->allowed_mime_types)) {
throw
new Exception
('Type of the uploaded file is not allowed. The accepted file types are: '.join(',<br />', $this->allowed_mime_types)); }
else
{
return true;
}
}
/**
* Check the extension of an uploaded file
* @return Exception - if not allowed, bool true if allowed
*/
protected function checkExtension()
{
if (!in_array($this->getExtension(), $this->allowed_extensions)) {
throw
new Exception
('The extension of an uploaded file is not allowed. The accepted file extensions a
re: '.join(', ', $this->allowed_extensions)); }
else
{
return true;
}
}
?>
To tylko wycinki klasy. Rozkmin Pan reszte sam:)
Pozdravki