Post by santanu2019 » Fri May 14, 2021 2:21 pm

After uploading the image folder to the server, am getting a bunch of errors on the frontend please see the warning message below

Warning: getimagesize(/home/sbmkskfv/public_html/image/catalog/danese/thum/Itka-table-lamp.jpg): failed to open stream: No such file or directory in /home/sbmkskfv/public_html/catalog/model/tool/image.php

I understand why the error is coming because the image/path is not matching to be case sensitive, I can't rename all the images because there are so many images in the image folder.
Image Path/Name is same but image name 'Itka-table-lamp.jpg' *I* capital letter in the database and *i* small letter in folder

Please help me to solve this issue.
Thank you.

Attachments

screenshot - image folder.PNG

screenshot - image folder.PNG (5.84 KiB) Viewed 1674 times


New member

Posts

Joined
Wed Jul 03, 2019 7:42 pm

Post by thekrotek » Fri May 14, 2021 3:06 pm

Try to add mb_strtolower() function to image.php file. Or something like that, I didn't check personally, just giving you a direction.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by paulfeakins » Fri May 14, 2021 4:26 pm

thekrotek wrote:
Fri May 14, 2021 3:06 pm
Try to add mb_strtolower() function to image.php file. Or something like that, I didn't check personally, just giving you a direction.
Doesn't seem like a good solution to me tbh.

I think the best solution would be to rename he images with a script.

Get in touch if you want to pay us to do it, it would be something like this:

Code: Select all

find my_root_dir -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
https://stackoverflow.com/questions/152 ... e-on-linux

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by thekrotek » Fri May 14, 2021 4:35 pm

paulfeakins wrote:
Fri May 14, 2021 4:26 pm
Doesn't seem like a good solution to me tbh.
Why not? This way you won't have to update image files and a single additional function won't hurt.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by JNeuhoff » Fri May 14, 2021 5:18 pm

If the actual image files all use lower-case letters in their names then yes, thekrotek's solution is the easiest one, using something like this in the catalog/model/tool/image.php:

Replace

Code: Select all

	public function resize($filename, $width, $height) {
		.....
	}

With

Code: Select all

	public function resize($filename, $width, $height) {
		$filename = mb_strtolower($filename);
		....
	}

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Fri May 14, 2021 8:54 pm

From the image it appears that you have image filenames with capitals and without.

Simply adding mb_strtolower on the retrieved filename from the database would only work if all filenames in the filesystem are lowercase.
It may solve this case for itka-table-lamp.jpg but it would break the case for Itka_pendant_lamp.jpg
So you would also have to make all your image filesystem lowercase for this to work or if it is incidental, manually adjust one or the other.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Fri May 14, 2021 10:48 pm

Renaming the files from console would be the right path since even though the mb_strtolower is used, the database could still previously have non-lowercase characters as opposed to the future time period where the uploads will be occurring.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon May 17, 2021 6:48 pm

straightlight wrote:
Fri May 14, 2021 10:48 pm
Renaming the files from console would be the right path
Thanks @straightlight, it's very obvious that modifying the site code just because your files are named differently to your database is nasty and hacky and I can't believe the devs above have suggested it tbh. Poor advice guys.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by joeantropy » Mon May 17, 2021 6:58 pm

santanu2019 wrote:
Fri May 14, 2021 2:21 pm
After uploading the image folder to the server ...

... Image Path/Name is same but image name 'Itka-table-lamp.jpg' *I* capital letter in the database and *i* small letter in folder
What I'm interested to know is... what were you using to upload the files that's converting all the filenames to lowercase? Pretty serious bug for any file uploader to be automatically mangling filenames like that.

Newbie

Posts

Joined
Mon Mar 02, 2020 10:19 pm

Post by straightlight » Mon May 17, 2021 7:04 pm

joeantropy wrote:
Mon May 17, 2021 6:58 pm
santanu2019 wrote:
Fri May 14, 2021 2:21 pm
After uploading the image folder to the server ...

... Image Path/Name is same but image name 'Itka-table-lamp.jpg' *I* capital letter in the database and *i* small letter in folder
What I'm interested to know is... what were you using to upload the files that's converting all the filenames to lowercase? Pretty serious bug for any file uploader to be automatically mangling filenames like that.
It's not a bug, it's server-wise based on its OS distribution.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon May 17, 2021 7:12 pm

straightlight wrote:
Mon May 17, 2021 7:04 pm
It's not a bug, it's server-wise based on its OS distribution.
I'd suggest that even on Windows it would be better to keep filenames and db entries with matching case.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Mon May 17, 2021 7:20 pm

paulfeakins wrote:
Mon May 17, 2021 7:12 pm
straightlight wrote:
Mon May 17, 2021 7:04 pm
It's not a bug, it's server-wise based on its OS distribution.
I'd suggest that even on Windows it would be better to keep filenames and db entries with matching case.
Windows server is not under client-servers' controls to manage these types of settings with IIS. Even though similarities of .htaccess could be used, these configurations are still in the hands of IT administrators as opposed to other OSes.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon May 17, 2021 7:25 pm

straightlight wrote:
Mon May 17, 2021 7:20 pm
Windows server is not under client-servers' controls to manage these types of settings with IIS. Even though similarities of .htaccess could be used, these configurations are still in the hands of IT administrators as opposed to other OSes.
I'm sure it's possible even on Windows to get the uploaded filename in the correct case?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Mon May 17, 2021 7:27 pm

paulfeakins wrote:
Mon May 17, 2021 7:25 pm
straightlight wrote:
Mon May 17, 2021 7:20 pm
Windows server is not under client-servers' controls to manage these types of settings with IIS. Even though similarities of .htaccess could be used, these configurations are still in the hands of IT administrators as opposed to other OSes.
I'm sure it's possible even on Windows to get the uploaded filename in the correct case?
Depending on the disk partitions being used on the server. Web users have no controls based on those configurations.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by JNeuhoff » Mon May 17, 2021 8:27 pm

The NTFS file system can store files with correct upper/lowercase characters in the file name.

However, by default, Windows processes treat the file system as case insensitive. They do not differentiate between files or folders based on case.

But Windows 10 now offers an optional case-sensitive file system, just like Linux and other UNIX-like operating systems. All Windows processes will handle case-sensitive files and folders properly if you enable this feature. In other words, they'll see “file” and “File” as two separate files.

See https://www.windowscentral.com/how-enab ... windows-10

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by santanu2019 » Tue May 25, 2021 2:16 pm

Thank you all I have solved this issue.

Code: Select all

$path = substr($temp_image_path, strrpos($temp_image_path, '/') + 1);
            $dir  = dirname($temp_image_path);
            
            if ($handle = opendir($dir)) {
                while (false !== ($entry = readdir($handle))) {
                    if (strtolower($path) == strtolower($entry)){
                        $temp_image_path = $dir . '/' . $entry ;
                    }
                }
                closedir($handle);
            }
Last edited by santanu2019 on Tue Jun 15, 2021 6:24 pm, edited 1 time in total.

New member

Posts

Joined
Wed Jul 03, 2019 7:42 pm

Post by straightlight » Tue May 25, 2021 7:46 pm

santanu2019 wrote:
Tue May 25, 2021 2:16 pm
Thank you all I have solved this issue.
What was the solution?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by santanu2019 » Tue Jun 15, 2021 6:26 pm

straightlight wrote:
Tue May 25, 2021 7:46 pm
santanu2019 wrote:
Tue May 25, 2021 2:16 pm
Thank you all I have solved this issue.
What was the solution?
I have edited my last comment with a solution

New member

Posts

Joined
Wed Jul 03, 2019 7:42 pm

Post by jrr » Tue Jul 13, 2021 4:12 am

Gah, I JUST realized that OC was case sensitive for (image) file names - I transferred thousands of images from my old system and some worked and others didn't but I had other things to do so I didn't worry about it and was going to get around to fixing it and.... Now I see that the case of the image directories and file names actually matters (it didn't on my previous setup - oscMax) and thus I wasn't paying attention and neither had I instructed my staff to worry about case.
So, now I have to get a couple of scripts working - once to rename all the files and directories on my server to lower case, the other to fix the database listings...as I said. Gah!
Any particular reason why OC (3.0.3.6 in my case) actually cares about case in file names and directories, or is that simply good programming practice? I missed that lesson...

jrr
Active Member

Posts

Joined
Mon Nov 20, 2017 1:48 pm
Who is online

Users browsing this forum: No registered users and 100 guests