lang['no_file'] = "No file was specified."; $this->lang['invald_ext'] = "The file does not have an accepted extension."; $this->lang['size'] = "The file is larger than the allowed file size."; $this->lang['err_upload'] = "An error occured while uploading the file. Please try again."; } function validExtension() { if ( in_array( $this->ext, $this->extensions ) ) return true; $this->error = $this->lang['invald_ext']; return false; } function validSize() { if ( $this->tmp_name ) { if ( $this->size <= $this->max_size ) return true; $this->error = $this->lang['size']; return false; } $this->error = $this->lang['err_upload']; return false; } function exists() { return false; } function upload( $file ) { if ( !is_array( $file ) ) { $this->error = $this->lang['no_file']; return false; } $this->tmp_name = trim( $file['tmp_name'] ); $this->file = trim( strtolower( $file['name'] ) ); $this->ext = ltrim( strtolower( strchr( $this->file, "." ) ), '.' ); $this->size = filesize( $this->tmp_name ); if ( $this->exists() || !$this->validSize() || !$this->validExtension() ) return false; if ( is_uploaded_file( $this->tmp_name ) ) if ( copy( $this->tmp_name, $this->dir . $this->file ) ) return true; return false; } } ?>