RisteDimitrievski
Active member
- Affected version
- 2.2.9
PHP:
public function getUploadedFilePath(\XF\Http\Upload $filename)
{
if($filename->isImage())
{
$visitor = XF::visitor();
$fname = $filename->getFileName();
$data = "data/{$visitor->user_id}/{$fname}";
return $data;
}
}
public function validateFile(\XF\Http\Upload $fileName)
{
if($fileName instanceof XF\Http\Upload)
{
$fileName->setAllowedExtensions(['jpg','png','jpeg']);
if($fileName->isValid())
{
$tempfile = $fileName->getTempFile();
$this->file->copyFileToAbstractedPath($tempfile,"data://{$visitor->user_id}/{$fileName->getFileName()}");
return $this->getUploadedFilePath($fileName);
}else
{
return false;
}
}
}
These functions are custom build in my controller to upload an image and then get a path.