i need some help with my file uploads class. The file goes through but doesn't get uploaded to my uploads directory.
upload.class.php
<?php
ini_set('post_max_size' , '550m');
ini_set('upload_max_filesize' , '550m');
ini_set('file_uploads' , '1');
class upload
{
const MAX_SIZE ="150000";
private static $file_name;
private static $file_type;
private static $file_size;
private static $file_tmp;
private static $file_errors;
private static $directory;
private static $allowed_types=array("application/arj",
"application/excel",
"application/gnutar",
"application/mspowerpoint",
"application/msword",
"application/octet-stream",
"application/onenote",
"application/pdf",
"application/plain",
"application/postscript",
"application/powerpoint",
"application/rar",
"application/rtf",
"application/vnd.ms-excel",
"application/vnd.ms-excel.addin.macroEnabled.12",
"application/vnd.ms-excel.sheet.binary.macroEnabled.12",
"application/vnd.ms-excel.sheet.macroEnabled.12",
"application/vnd.ms-excel.template.macroEnabled.12",
"application/vnd.ms-office",
"application/vnd.ms-officetheme",
"application/vnd.ms-powerpoint",
"application/vnd.ms-powerpoint.addin.macroEnabled.12",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12",
"application/vnd.ms-powerpoint.slide.macroEnabled.12",
"application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
"application/vnd.ms-powerpoint.template.macroEnabled.12",
"application/vnd.ms-word",
"application/vnd.ms-word.document.macroEnabled.12",
"application/vnd.ms-word.template.macroEnabled.12",
"application/vnd.oasis.opendocument.chart",
"application/vnd.oasis.opendocument.database",
"application/vnd.oasis.opendocument.formula",
"application/vnd.oasis.opendocument.graphics",
"application/vnd.oasis.opendocument.graphics-template",
"application/vnd.oasis.opendocument.image",
"application/vnd.oasis.opendocument.presentation",
"application/vnd.oasis.opendocument.presentation-template",
"application/vnd.oasis.opendocument.spreadsheet",
"application/vnd.oasis.opendocument.spreadsheet-template",
"application/vnd.oasis.opendocument.text",
"application/vnd.oasis.opendocument.text-master",
"application/vnd.oasis.opendocument.text-template",
"application/vnd.oasis.opendocument.text-web",
"application/vnd.openofficeorg.extension",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.openxmlformats-officedocument.presentationml.slide",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
"application/vnd.openxmlformats-officedocument.presentationml.template",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
"application/vocaltec-media-file",
"application/wordperfect",
"application/x-bittorrent",
"application/x-bzip",
"application/x-bzip2",
"application/x-compressed",
"application/x-excel",
"application/x-gzip",
"application/x-latex",
"application/x-midi",
"application/xml",
"application/x-msexcel",
"application/x-rar-compressed",
"application/x-rtf",
"application/x-shockwave-flash",
"application/x-sit",
"application/x-stuffit",
"application/x-troff-msvideo",
"application/x-zip",
"application/x-zip-compressed",
"application/zip",
"audio/*",
"image/jpg",
"image/jpeg",
"image/png",
"image/gif",
"multipart/x-gzip",
"multipart/x-zip",
"text/plain",
"text/rtf",
"text/richtext",
"text/xml",
"video/*");
public static function upload_file($filenames)
{
if($_FILES['userfile']['error']==0)
{
self::$file_name = $filenames;
}
return self::$file_name;
}
public static function is_allowed_type($filetypes)
{
echo $filetypes;
if($_FILES['userfile']['error']== 0 && in_array($filetypes , self::$allowed_types))
{
self::$file_type = $filetypes;
}
else
{
throw new Exception('File Type Is Not An Allowed Type Please Only Upload Files that are Allowed Types');
}
return self::$file_type;
}
public static function is_allowed_size($filesizes)
{
if($filesizes < self::MAX_SIZE)
{
self::$file_size = $filesizes;
}
elseif($filesizes > self::MAX_SIZE )
{
throw new Exception('Fatal Error Filesize is to large');
}
return self::$file_size;
}
public static function upload_dir($destination)
{
if($destination == 'defualt' && file_exists('uploads'))
{
self::$directory = '/uploads';
}
elseif($destination != 'defualt' && file_exists($destination))
{
self::$directory = $destination;
}
elseif($destination !='defualt' && !file_exists($destination))
{
throw new Exception('Fatal Upload Error Directory Does not Exsist');
}
return self::$directory;
}
public static function upload_error($fileerror)
{
if($_FILES['userfile']['error'] != 0)
{
trigger_error('Fatal File Upload Error Type:'. print_r($_FILES['error']));
}
}
public static function file_uploaded($filetmpname)
{
if(is_uploaded_file($filetmpname))
{
self::$file_tmp = $filetmpname;
move_uploaded_file(self::$file_name , self::$directory);
}
return self::$file_tmp;
}
}
functions
include('upload.class.php');
$upload = new upload;
$upload->upload_file($_FILES['userfile']['name']);
$upload->is_allowed_type($_FILES['userfile']['type']);
$upload->is_allowed_size($_FILES['userfile']['size']);
$upload->upload_error($_FILES['userfile']['error']);
$upload->upload_dir('defualt');
$upload->file_uploaded($_FILES['userfile']['tmp_name']);