CodeIgniter Forums
some wrong with upload - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: some wrong with upload (/showthread.php?tid=66671)



some wrong with upload - startbbs - 11-19-2016

view file
PHP Code:
<form method="post" action="" enctype="multipart/form-data">
<
input type="file" name="f1">
<
input type="submit" name="submit">
</
form

Controllers file
PHP Code:
    public function upload()
    {
        if(
$_POST){
            
$file $this->request->getFile('f1');
            
$newName $file->getRandomName();
            if (
$file->isValid() && ! $file->hasMoved()){
                
$file->move(WRITEPATH.'uploads'$newName);
            }
        }
        echo 
view('upload');


I got the error

Code:
Method CodeIgniter\HTTP\Header::__toString() must not throw an exception, caught ErrorException: Array to string conversion

May I know where the wrong is? thanks


RE: some wrong with upload - ridho - 11-19-2016

I fixed this problem. The pull request https://github.com/bcit-ci/CodeIgniter4/pull/308 until now still not merged.


RE: some wrong with upload - startbbs - 11-19-2016

(11-19-2016, 07:54 PM)ridho Wrote: I fixed this problem. The pull request https://github.com/bcit-ci/CodeIgniter4/pull/308 until now still not merged.

Thanks a lot, Ridho.