Welcome Guest, Not a member yet? Register   Sign In
File upload work on php 7.2, but not on 7.4.14
#1

(This post was last modified: 01-20-2021, 02:48 AM by t_5810.)

I have an Codeigniter app, which works like a charm on PHP 7.2
After moving on PHP 7.4.14, I get an error "No input file specified." Search on Google suggested that I should add a question mark in my .htaccess file
Code:
RewriteRule ^([\s\S]*)$ index.php?/$1 [L,NC,QSA]
to resolve the issue. And that was the only change that I did. However, I notice that since the upgrade, my code for uploading images does not work (application wide).
I have options to upload images on many pages, and they all works if I switch back to PHP 7.2, but does not work on PHP 7.4.14
The error that I get is:
finfo_file(): Empty filename or path
My validation code is the following:


Code:
// Thumbnail image is not required, so validation is optional
$webpageThumbnailImage = $this->request->getFile('webpageThumbnailImage');
    if ($webpageThumbnailImage != "") {
        if (!($this->validate([
            'webpageThumbnailImage'            => [
            'uploaded[webpageThumbnailImage]',
            'mime_in[webpageThumbnailImage,image/jpg,image/jpeg,image/gif,image/png,image/bmp]',
                        'max_size[webpageThumbnailImage,4096]',
            ],
        ]))) {
        // Validation has failed, redirect the user back
        return redirect()->to(base_url() . '/Backend/Webpage/edit_record/' . $this->request->getPost('webpageID'))->withInput();
    }
    if (!$webpageThumbnailImage->isValid()) {
        throw new RuntimeException($webpageThumbnailImage->getErrorString() . '(' . $webpageThumbnailImage->getError() . ')');
    }
    $newName = $webpageThumbnailImage->getRandomName();
    $webpageThumbnailImage->move('./backOffice/backOfficeImages/', $newName);
} else {
    $newName = NULL;
}

Questions is: Why this code works on PHP 7.2 and does not work on PHP 7.4.14?
Reply
#2

(This post was last modified: 01-20-2021, 04:11 AM by InsiteFX.)

Well it can be anything, also you did not specify what version of CodeIgniter you are running.

Read the change logs.

PHP 7 ChangeLog
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 01-20-2021, 04:28 AM by t_5810.)

Thanks for your reply, and for spending your time to help me.

(01-20-2021, 04:10 AM)InsiteFX Wrote: Well it can be anything, also you did not specify what version of CodeIgniter you are running.

Read the change logs.

PHP 7 ChangeLog

My bad. Thanks for pointing that to me. CodeIgniter version is: 4.04 CI

As far for the log error, here it is:

Code:
CRITICAL - 2021-01-20 11:46:12 --> finfo_file(): Empty filename or path
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'finfo_file(): E...', 'D:\\Sites\\ea3\\sy...', 153, Array)
#1 D:\Sites\ea3\system\Files\File.php(153): finfo_file(Resource id #129, '')
#2 D:\Sites\ea3\system\Validation\FileRules.php(251): CodeIgniter\Files\File->getMimeType()
#3 D:\Sites\ea3\system\Validation\Validation.php(325): CodeIgniter\Validation\FileRules->mime_in(NULL, Array, Array, NULL)
#4 D:\Sites\ea3\system\Validation\Validation.php(189): CodeIgniter\Validation\Validation->processRules('webpageThumbnai...', 'webpageThumbnai...', NULL, Array, Array)
#5 D:\Sites\ea3\system\Controller.php(219): CodeIgniter\Validation\Validation->run()
#6 D:\Sites\ea3\app\Controllers\Backend\Webpage.php(190): CodeIgniter\Controller->validate(Array)
#7 D:\Sites\ea3\system\CodeIgniter.php(918): App\Controllers\Backend\Webpage->edit_record()
#8 D:\Sites\ea3\system\CodeIgniter.php(404): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Backend\Webpage))
#9 D:\Sites\ea3\system\CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#10 D:\Sites\ea3\public\index.php(45): CodeIgniter\CodeIgniter->run()
#11 {main}
Reply
#4

If you look at the 7.4.14 change log I believe they fixed a bug for the finfo_file().

This maybe a new bug in CI not sure but you can report it to the developmen5t team on GitHub
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