Welcome Guest, Not a member yet? Register   Sign In
File upload validation still incorrect?
#2

i'm using Ci4 and having no problems with upload .

I start with :

Code:
$file = $this->request->getFile('userfile');
                $name= $file->getName();
                $tempfile = $file->getTempName();

the move bit is:

Code:
$file->move('blogImages',$name);

now with ->isValid()

personally i don't like it, because i'm a control freak ,so i don't use it . instead i have a utiliy class which for the image does a series of checks


eg



Code:
function getFileSize($tmpName)
    {
    $this->fileTmpName = $tmpName;
    $this->fileSize= filesize($this->fileTmpName);
    return $this->fileSize;        
        
   }

So first i check to see if image already exists in directory blogImages, i decide 250 kb is maximum to upload, if img bigger than that i message is fed back to form for upl0ading image , that image is too big , i check extension of image . By doing my own checks i understand it , so i know how to update and it works the way i want
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply


Messages In This Thread
RE: File upload validation still incorrect? - by captain-sensible - 11-05-2021, 04:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB