1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- defined('GNUSOCIAL') || die;
- class AvatarAction extends Action
- {
- public $filename = null;
- public $filepath = null;
- public $mimetype = null;
- protected function prepare(array $args = [])
- {
- parent::prepare($args);
- $this->filename = File::tryFilename($this->trimmed('file'));
- $this->filepath = File::path($this->filename, common_config('avatar', 'dir'), false);
- if (!file_exists($this->filepath)) {
-
- $this->clientError(_m('No such avatar.'), 404);
- }
- $this->mimetype = (new ImageFile(-1, $this->filepath))->mimetype;
- return true;
- }
- protected function handle()
- {
- parent::handle();
- common_send_file($this->filepath, $this->mimetype, $this->filename, 'inline');
- }
- }
|