ResponsiveFilemanager
ResponsiveFilemanager copied to clipboard
Problem with php 8
Hi Run a test on php 8 and there are several issues. Started with
mb_http_input('UTF-8'); Fatal error: Uncaught ValueError: mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I", or "L"
Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in
And uploading fails. No error reporting about any issues and thumbs are not created.
All works fine in the latest php 7.x
Same error
Replace mb_http_input('UTF-8'); with mb_http_input(); inside /filemanager/config/config.php line 49
It will now give you error saveImage: This is not a resource when you upload jpg image and will not create thumb images because of in PHP 8.0.0 | On success, imagecreatefromjpeg function returns a GDImage instance now; previously, a resource was returned.
Reference: imagecreatefromjpeg
To resolve this issue go to:
filemanager/include/php_image_magician.php
find ! is_resource and check object must be instanceof \GdImage
Like if ( ! is_resource($this->imageResized) && !($this->imageResized instanceof \GdImage)) on line 2791
Reference: https://php.watch/versions/8.0/gdimage
Thanks!
The latest release is outdated. I'm able to use the current master branch all the way up to the current release candidate for PHP 8.1 . You could download the latest master branch instead of the latest release or you could apply these fixes manually to fix the PHP 8 issues: https://github.com/trippo/ResponsiveFilemanager/pull/657
any plans for a new release including PHP 8 fixes? The last release was from 2019. Is this project dead?
@Darksymphony75 Follow the answer of @faisalrehmanlums . After that, you will need to replace some code in UploadHandler.php. See the Cliver Corner's answer: https://stackoverflow.com/questions/60544865/responsive-file-manager-and-tinymce/60552341#60552341
Hope it will work for you. It works well by my side with PHP 8.1.1 :)
If you have the same problem with your local server, please follow those steps:
I saw that there is an error in the file "UploadHandler.php" in line 1081. In PHP8, the second parameter for "implode" need to be an array :
Replace this code
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode($failed_versions, ', ').')'; }
With
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode(' ', $failed_versions).')'; }
Then, you need to enable an extension via the PHP.ini from your local server by uncommenting: extension=gd
And now, you can upload any file without any error. You will also see the thumbnail properly :)
(Source: https://stackoverflow.com/questions/7851011/how-do-i-install-gd-on-my-windows-server-version-of-php)
Thank you, I will have a look and try that. However it is such a do it yourself solution, that can cause chaos in the future. I don't know why it is not officialy implemented in some new version. Or if the author is not maintaining the project anymore, someone should take it over and work on it. It is one of the last free filemanagers left, also the Roxyfileman is already dead.
You are right. It's not 100% secure in the future. But it made the job actually. It's one of the greatest filemanager I used since 2014 for multiples projects. Imagine updating each of your webproject...
Maybe a simple drag&drop filemanager can do the job to replace that filemanager. Easy to update and easy to understand. It can be an interesting project to do ^^
This filemanager is also an alternative : https://tinyfilemanager.github.io/
I'm getting a 500 server error from mb_http_input(), whether it's passing UTF-8 or not. I can't get to the bottom of why this is, but if I comment that line out, all seems to work OK. Hope this may help someone else out.
Hi, i'm currenly facing an issue with SyntaxError: Unexpected token < in JSON at position 0
. Do you have some tips how to fix this?
@LeMatosDeFuk Hey. Where do you see this error and in which file?
Hi, for me, After uploading the file. Of course, the upload is successful. See the image below: https://s6.uupload.ir/files/untitled_sz4z.png
@protokoll-studio Same for me as @ehsan1011.
@ehsan1011 & @LeMatosDeFuk I also have this kind of error in localhost but not live version. I was trying to find a solution but stopped the research since 2 weeks. I will go back to it asap
@protokoll-studio I've just tried it on live server and I can confirm that this is happening only on local server.
@LeMatosDeFuk Happy to read that. We can now focus on the local server. I saw that there is an error in the file "UploadHandler.php" in line 1081. In PHP8, the second parameter for implode need to be an array. Okay but... What does it work in live server?
Replace this code
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode($failed_versions, ', ').')'; }
With
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode(' ', $failed_versions).')'; }
Now, you get a "nicer" error after the upload: The GD Library is not installed.
You can fix that by adding the line (or uncommenting) in your PHP.ini (in local server): extension=gd
And now, you can upload any file without any error. You will also see the thumbnail properly :)
(Source: https://stackoverflow.com/questions/7851011/how-do-i-install-gd-on-my-windows-server-version-of-php)
@LeMatosDeFuk Happy to read that. We can now focus on the local server. I saw that there is an error in the file "UploadHandler.php" in line 1081. In PHP8, the second parameter for implode need to be an array. Okay but... What does it work in live server?
Replace this code
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode($failed_versions, ', ').')'; }
With
if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') .' ('.implode(' ', $failed_versions).')'; }
Now, you get a "nicer" error after the upload: The GD Library is not installed.
You can fix that by adding the line (or uncommenting) in your PHP.ini (in local server): extension=gd
And now, you can upload any file without any error. You will also see the thumbnail properly :)
(Source: https://stackoverflow.com/questions/7851011/how-do-i-install-gd-on-my-windows-server-version-of-php)
Thank you, but unfortunately it still shows the same error. Although gd is enable on xampp.
@ehsan1011 Nooo :( Even after restarting the server? What's the error you get in the dev console?
@protokoll-studio Yes, always have GD enabled. dev has no error, just XHR finished loading: POST "http://localhost/.../filemanager/upload.php"
However, by commenting on that line (if (count($failed_versions))...), it still shows the error.
@ehsan1011 Check in the dev tool the file called "UploadHandler.php" and/or "upload.php" . You need to check if there is a "Fatal error" or something else. Because if you have the error in the filemanager (UI), you need to have the error in the dev tool
I got the same issue, it shows SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data That's because there are some PHP errors returned in the AJAX response:
- Deprecated: basename(): Passing null to parameter #2 ($suffix) of type string is deprecated in UploadHandler.php on line 1593
- Deprecated: basename(): Passing null to parameter #2 ($suffix) of type string is deprecated in UploadHandler.php on line 1593
- Warning: Trying to access array offset on value of type null in UploadHandler.php on line 496
- Warning: Trying to access array offset on value of type null in UploadHandler.php on line 1429
Fix for 1&2: replace function basename($filepath, $suffix = null) {
with function basename($filepath, $suffix = '') {
in UploadHandler.php
Fix for 3 & 4: #591