Connecting Tech Pros Worldwide Forums | Help | Site Map

quotes in file names

Balaskas Evaggelos
Guest
 
Posts: n/a
#1: Sep 7 '06
Hi to all,

I am developing a php web browser application.

But i have a problem.

I am listing with opendir but there are a lot of files with
quotes in their names.

example: News Letter for "ebal" today.html
(yes the above is only one file !!!)

When i browsing the files the listing doesn't show me the full name of
my files, because of the quotes in the filename.

Any ideas?

php 4.4.4

best regards,
-ebal

Noodle
Guest
 
Posts: n/a
#2: Sep 7 '06

re: quotes in file names


You could use the htmlspecialchars function to convert the quotes to
" for browser display.

http://au.php.net/manual/en/function...ecialchars.php



Balaskas Evaggelos wrote:
Quote:
Hi to all,
>
I am developing a php web browser application.
>
But i have a problem.
>
I am listing with opendir but there are a lot of files with
quotes in their names.
>
example: News Letter for "ebal" today.html
(yes the above is only one file !!!)
>
When i browsing the files the listing doesn't show me the full name of
my files, because of the quotes in the filename.
>
Any ideas?
>
php 4.4.4
>
best regards,
-ebal
Balaskas Evaggelos
Guest
 
Posts: n/a
#3: Sep 7 '06

re: quotes in file names


Noodle wrote:
Quote:
You could use the htmlspecialchars function to convert the quotes to
" for browser display.
>
http://au.php.net/manual/en/function...ecialchars.php
>
doesn't work,

because my special char is double quote "
and not 2 quotes ('') as opedir gives me.

---

The problem is in opendir function.
The opendir function read the filename with double quotes.
Do you thing this is a bug?

I changed the php.ini config about quotes but still the opendir
convert the double quotes in two quotes.
Noodle
Guest
 
Posts: n/a
#4: Sep 8 '06

re: quotes in file names



Balaskas Evaggelos wrote:
Quote:
Noodle wrote:
Quote:
You could use the htmlspecialchars function to convert the quotes to
" for browser display.

http://au.php.net/manual/en/function...ecialchars.php
>
doesn't work,
>
because my special char is double quote "
and not 2 quotes ('') as opedir gives me.
>
---
>
The problem is in opendir function.
The opendir function read the filename with double quotes.
Do you thing this is a bug?
>
I changed the php.ini config about quotes but still the opendir
convert the double quotes in two quotes.
You may not be using the function correctly. From the manual...

'"' (double quote) becomes '"' when ENT_NOQUOTES is not set ... If
ENT_QUOTES is set, both single and double quotes are translated and if
ENT_NOQUOTES is set neither single nor double quotes are translated.

The following code works for me:

<?php
if ($handle = opendir('.')) {
echo '<ul>';
while (false !== ($file = readdir($handle))) {
echo '<li>' . htmlspecialchars($file) . '</li>';
}
echo '</ul>';
closedir($handle);
}
?>

Closed Thread