Cannot reproduce \XF\Http\Upload sometimes return false on images

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;
           }
       }
   }
The image i was trying to upload is a JPG.
These functions are custom build in my controller to upload an image and then get a path.
 
There isn't a reproduction case with this bug report so we're not immediately seeing what changes, if any, we need to make.
 
Back
Top Bottom