0

For a project I'm working on, lots and lots of jpg files need to be converted to thumbnails and shown on a website. It is not complicated to read a directory, filter out all the jpg files and create thumbnails. So far no problem.

But.... Some files do contain characters like this: äÇé

And now the problems start. The php file creates the html file also, with this meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8559-1"/>

The jpg files are shown inside a table and just before this I have:

$filename=utf8_decode($url_path.'/'.$jpg_file);

When I look at it on the Linux box, everything goes fine. All images are there the way it should be. However, opening it from a Windows XP machine (firefox or ie doesn't matter), the images that contain umlauts doesn't show up.

Looking in the directory;
	on the Linux box	FELGENTRÄ□GER....jpg
	from Windows		FELGENTRÄGER....jpg
Firebug:
	on Linux		FELGENTRÄGER....jpg
	on Windows		FELGENTRÄGER....jpg
Firefox:
	image props in Linux	FELGENTR%C3%84GER...jpg
	image props on Windows	? (image is not shown)

What is going on. And how to correct it? (when I use uft8_encode the images don't show up anywhere).

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by colweb
0

Maybe you could rename the images? Like: 1.jpg - 1599295.jpg

Renaming is not an option. The file name is also used. As you can see, the file names are names of people and are build like "full name_company_country" and in the php file I seperate the elements and display this under the image.

0

You really want to avoid accented characters. If the problem is to do with accented characters - the changing of the names is the only option - well the easiest anyway.

"full name_company_country.jpg" is probably not the best way to name an image. You could save the image as suggested earlier, with a reference (country, name, company) in a DB table.

Giving users the ability to give images a name is dangerous unless you properly clean/validate.

user table
user_id
username
country
company
image_url

Simple.

0

After a long time of trying a lot of different solutions, it turns out to be simple. In my post I forgot to mention that the php-script runs on a Linux box but it must be possible to run it under Apache on a stand alone Win-XP machine.

All I had to do is insert the following in my php code:

if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {$charset="iso-8559-1"} else {$charset="UTF-8";}

And there where the html page is created:

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>"/>

The script now reads a directory without any decoding or encoding of the file names. Only before the table is build, the filename goes throught uft8_decode (but only if running on Linux). Now it works on Linux (from Linux and Windows) and on Windows.

Edited by colweb: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.