Ralph Freshour <ra***@primemail.com> writes:
I have a PHP web app using MySQL - when I save a .jpg file named
test's.jpg I see that the filename on the unix server is: test\'s.jpg
What software are you using to save the .jpg file? What software
are you using to display the filename? Depending on what you're
using, a file named test's.jpg might have the apostrophe escaped
as \' for display purposes, even though the backslash (\) isn't
really part of the name.
ls doesn't usually escape apostrophes, so if ls shows a backslash
then it's probably really part of the filename.
- the filename I end up saving in my SQL table is named test's.jpg -
when I use an image tag to display the photo on my web page, no image
displays.
What exactly does your IMG tag look like? Have you checked if the
problem is file permissions or file location instead of the file
name?
I tried to strip the slash out of the filename but the image still
won't display on the web page - maybe I'm all goofed up here and don't
understand what's going on with this slash char in the filename on the
server - can someone please help me to figure out how to get the image
to display on the web page?
It's usually wise to avoid filenames with characters that have
special meaning to shells or other software. Single-quotes
(apostrophes), double-quotes, spaces, semicolons, and a few other
characters are all special to most Unix shells and may require
escaping with a backslash (\) character, depending on what you're
doing. Nevertheless, such characters can be used in filenames, and
you should be able to use those filenames in IMG tags, although you
might need to do URL encoding of certain characters; in PHP, for
example, you can do this with urlencode(). Here are the encodings
for a couple of filenames:
test's => test%27s
test\'s => test%5C%27s
Hope this helps.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/