By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,883 Members | 2,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,883 IT Pros & Developers. It's quick & easy.

Saving filenames on unix server with apostrophe in filename help needed

P: n/a
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
- 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.

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?

Thanks...

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
*** Ralph Freshour wrote/escribió (Wed, 12 Nov 2003 06:22:02 GMT):
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
- 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.


You need to use urlencode() to convert "test's.jpg" into "test%27s.jpg".
Please note you must follow URLs rules; using backslash is just a typical
shell trick.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2

P: n/a
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/
Jul 17 '05 #3

P: n/a

"Michael Fuhr" <mf***@fuhr.org> wrote in message
news:3f********@omega.dimensional.com...
Ralph Freshour <ra***@primemail.com> writes:
[...], 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.


Ralph might also want to try rawurlencode(). I've found that urlencode()
turns spaces into pluses "+", whereas the raw version does the job correctly
(<space> -> %20). Many *nix's *sh'es accept these characters in command line
so you will only need the commands to generate html tags.

B.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.