Welcome Guest, Not a member yet? Register   Sign In
finfo_file(C:\Users\acer\AppData\Local\Temp\php19BC.tmp): Failed to open stream: No s
#1
Exclamation 
(This post was last modified: 07-02-2024, 11:17 PM by ozornick. Edit Reason: Edit code format )

when i create function store to insert data into database it fine until i'm working the file, the image has been moved but why i got this error? please help me ?


PHP Code:
public function store()
    {
        $getImage $this->request->getFile('image');

        if ($getImage->getError() === 4) {
            if ($this->request->getPost('gender') == 'male') {
                $getImageName "default_male.svg";
            } else {
                $getImageName "default_female.svg";
            }
        } else {
            $getImageName $getImage->getRandomName();
            $getImage->move('img/uploadedImg'$getImageName);
        }

        $data = [
            'name' => $this->request->getPost('name'),
            'email' => $this->request->getPost('email'),
            'username' => $this->request->getPost('username'),
            'gender' => $this->request->getPost('gender'),
            'major' => $this->request->getPost('major'),
            'address' => $this->request->getPost('address'),
            'phone' => $this->request->getPost('phone'),
            'image' => $getImageName
        
];

        if ($this->students->save($data) === false) {
            $errors $this->students->errors();
            return redirect()->to('student/create')->withInput()->with('errors'$errors);
        } else {
            session()->setFlashdata('insert''student added!');
            return redirect()->to('student');
        }
    


this the controller.
Reply
#2

What a mistake?
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3

(07-02-2024, 11:18 PM)ozornick Wrote: What a mistake?
finfo_file(C:\Users\acer\AppData\Local\Temp\php348.tmp): Failed to open stream: No such file or directory

i got this errror
Reply
#4

Maybe check that you did get a file.

PHP Code:
<?php

$getImage 
$this->request->getFile('image');

if (! 
$getImage->isValid()) {
    throw new \RuntimeException($getImage->getErrorString() . '(' $getImage->getError() . ')');

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(07-04-2024, 12:46 AM)InsiteFX Wrote: Maybe check that you did get a file.

PHP Code:
<?php

$getImage 
$this->request->getFile('image');

if (! 
$getImage->isValid()) {
    throw new \RuntimeException($getImage->getErrorString() . '(' $getImage->getError() . ')');


same dude, the dir failed to open stream
Reply
#6

You do know that the file upload class has a method called store right.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB