• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use Uploaded Files Library

#1
I want upload some files in a Codeigniter4 program

The method in Controller:
Code:
<?php
namespace App\Controllers;
use CodeIgniter\Controller;


class Test extends Controller
{
    ……

    public function get(){
        $file = $this->request->getFile('thumbnail');
        dd($file->getName());
    }
    ……

Result(ci.com/test/get):
Quote:Error
Call to a member function getName() on null

How to use Uploaded Files Library?

Thanks!

This problem has been solved:
The upload file form must contain enctype="multipart/form-data"

Like this:
Code:
<form action="upload_file.php" method="post" enctype="multipart/form-data">
Reply

#2
First Register service

Code:
$file = new \CodeIgniter\Files\File($path);
$file = $this->request->getFile('thumbnail');
        dd($file->getName());
Reply

#3
(09-02-2019, 11:10 PM)rmcdahal Wrote: First Register service

Code:
$file = new \CodeIgniter\Files\File($path);
$file = $this->request->getFile('thumbnail');
        dd($file->getName());


I tried this,but got en error:

ErrorException

Undefined variable: path
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.