Displaying image paths with spaces
Displaying image paths with spaces
am 07.09.2009 06:40:45 von Skip Evans
Hey all,
I have a CMS system that uses the FCKeditor to allow users to
create directories in which to store images. FCK allows users
to create directories with spaces in them, and it's pretty
deep in the JavaScript code so modifying that is not a simple
option, so at this point I'm trying to work from the
assumption that the users will continue to be allowed to
create directory names with spaces.
All that said, the CMS outputs data in two ways. I'll start
with the second method because it works and then move on to
the problem.
What the user has created in the FCKeditor is a path to an
image that appears like this:
src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1compressed.jpg"
Notice the '%20' codes for the spaces in the directory names
like 'Event images' and 'Show ads'.
The first way the code is displayed is with an AJAX call. It's
read on the PHP side, echo'd back out to the JavaScript code
and inserted into an ID with an innerHTML assignment. This
method works.
The first way the code is loaded is pure PHP. It's read from
the database just as it appears above and then echo'd back to
the browser. However, in the browser it appears like this:
/clients/client_118/images//Event\ images/Show\
ads/catspaw1compressed.jpg
And of course the browser can't display the image with those
'\ ' combinations.
So my task is to get it to display the image properly on the
pure PHP side the same way it does via the AJAX call.
I should also say that the code the image path resides in
contains a text, etc, so it's a block of content, containing
both text and image paths.
Is there a way to read and echo this on the PHP side and
preserve a properly displayable path like the AJAX call, but
that also won't interfere with the rest of the HTML and text
code contained within the block of content?
I'm stumped on this one, so any help would be greatly,
wonderfully, blissfully even....... appreciated.
Thanks,
Skip
--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Displaying image paths with spaces
am 07.09.2009 10:01:12 von Ashley Sheridan
On Sun, 2009-09-06 at 23:40 -0500, Skip Evans wrote:
> Hey all,
>
> I have a CMS system that uses the FCKeditor to allow users to
> create directories in which to store images. FCK allows users
> to create directories with spaces in them, and it's pretty
> deep in the JavaScript code so modifying that is not a simple
> option, so at this point I'm trying to work from the
> assumption that the users will continue to be allowed to
> create directory names with spaces.
>
> All that said, the CMS outputs data in two ways. I'll start
> with the second method because it works and then move on to
> the problem.
>
> What the user has created in the FCKeditor is a path to an
> image that appears like this:
>
> src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1compressed.jpg"
>
> Notice the '%20' codes for the spaces in the directory names
> like 'Event images' and 'Show ads'.
>
> The first way the code is displayed is with an AJAX call. It's
> read on the PHP side, echo'd back out to the JavaScript code
> and inserted into an ID with an innerHTML assignment. This
> method works.
>
> The first way the code is loaded is pure PHP. It's read from
> the database just as it appears above and then echo'd back to
> the browser. However, in the browser it appears like this:
>
> /clients/client_118/images//Event\ images/Show\
> ads/catspaw1compressed.jpg
>
> And of course the browser can't display the image with those
> '\ ' combinations.
>
> So my task is to get it to display the image properly on the
> pure PHP side the same way it does via the AJAX call.
>
> I should also say that the code the image path resides in
> contains a text, etc, so it's a block of content, containing
> both text and image paths.
>
> Is there a way to read and echo this on the PHP side and
> preserve a properly displayable path like the AJAX call, but
> that also won't interfere with the rest of the HTML and text
> code contained within the block of content?
>
> I'm stumped on this one, so any help would be greatly,
> wonderfully, blissfully even....... appreciated.
>
> Thanks,
> Skip
> --
> ====================================
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> ------------------------------------
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
>
How are you outputting those URLs? PHP won't just automatically converty
'%20' to a '\ '.
What is the raw URL format you're getting from FCKEditor?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Displaying image paths with spaces
am 07.09.2009 19:14:48 von Skip Evans
Ashley Sheridan wrote:
>
> How are you outputting those URLs? PHP won't just automatically converty
> '%20' to a '\ '.
>
> What is the raw URL format you're getting from FCKEditor?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
The raw code in the FCKeditor looks like this:
src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1compressed.jpg"
(withing an tag of course)
But when the page displays and the images do not appear,
viewing the image's properties shows this: (Notice the %5C).
That %5C is what I think is being converted to a slash. Why it
shows up is baffling me.
http://penguinsites.com/clients/client_118/images//Event%5C% 20images/Show%5C%20ads/catspaw1compressed.jpg
I simply output the code from the FCKeditor with a plain echo
to the browser.
But then if I right-click the image to view it, that's when I
see this
The requested URL /clients/client_118/images//Event\
images/Show\ ads/catspaw1compressed.jpg was not found on this
server.
So it seems it's not preserving the %20 as coded spaces, and
also converting that %5C to a slash!
Whaaaa????
Thanks,
Skip
--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Displaying image paths with spaces
am 07.09.2009 19:23:42 von Ashley Sheridan
On Mon, 2009-09-07 at 12:14 -0500, Skip Evans wrote:
> Ashley Sheridan wrote:
> >
> > How are you outputting those URLs? PHP won't just automatically converty
> > '%20' to a '\ '.
> >
> > What is the raw URL format you're getting from FCKEditor?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
>
> The raw code in the FCKeditor looks like this:
>
> src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1compressed.jpg"
>
> (withing an tag of course)
>
> But when the page displays and the images do not appear,
> viewing the image's properties shows this: (Notice the %5C).
> That %5C is what I think is being converted to a slash. Why it
> shows up is baffling me.
>
> http://penguinsites.com/clients/client_118/images//Event%5C% 20images/Show%5C%20ads/catspaw1compressed.jpg
>
> I simply output the code from the FCKeditor with a plain echo
> to the browser.
>
> But then if I right-click the image to view it, that's when I
> see this
>
> The requested URL /clients/client_118/images//Event\
> images/Show\ ads/catspaw1compressed.jpg was not found on this
> server.
>
> So it seems it's not preserving the %20 as coded spaces, and
> also converting that %5C to a slash!
>
> Whaaaa????
>
> Thanks,
> Skip
>
> --
> ====================================
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> ------------------------------------
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
>
I believe %5C is the http code for %.
Are you saying then that FCKEditor is sending the %20 encoded URL when
you submit the form? I've not had any problems using FCKEditor myself.
Have you tried using str_replace('%20', ' ', $url) on the URL when you
receive it from the form?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Displaying image paths with spaces
am 07.09.2009 21:24:37 von HallMarc Websites
> -----Original Message-----
> From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
> Sent: Monday, September 07, 2009 1:24 PM
> To: Skip Evans
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Displaying image paths with spaces
>
> On Mon, 2009-09-07 at 12:14 -0500, Skip Evans wrote:
> > Ashley Sheridan wrote:
> > >
> > > How are you outputting those URLs? PHP won't just automatically
> converty
> > > '%20' to a '\ '.
> > >
> > > What is the raw URL format you're getting from FCKEditor?
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> >
> > The raw code in the FCKeditor looks like this:
> >
> >
> src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1comp
> ressed.jpg"
> >
> > (withing an tag of course)
> >
> > But when the page displays and the images do not appear,
> > viewing the image's properties shows this: (Notice the %5C).
> > That %5C is what I think is being converted to a slash. Why it
> > shows up is baffling me.
> >
> >
> http://penguinsites.com/clients/client_118/images//Event%5C% 20images/Sh
> ow%5C%20ads/catspaw1compressed.jpg
> >
> > I simply output the code from the FCKeditor with a plain echo
> > to the browser.
> >
> > But then if I right-click the image to view it, that's when I
> > see this
> >
> > The requested URL /clients/client_118/images//Event\
> > images/Show\ ads/catspaw1compressed.jpg was not found on this
> > server.
> >
> > So it seems it's not preserving the %20 as coded spaces, and
> > also converting that %5C to a slash!
> >
> > Whaaaa????
> >
> > Thanks,
> > Skip
> >
> > --
> > ====================================
> > Skip Evans
> > Big Sky Penguin, LLC
> > 503 S Baldwin St, #1
> > Madison WI 53703
> > 608.250.2720
> > http://bigskypenguin.com
> > ------------------------------------
> > Those of you who believe in
> > telekinesis, raise my hand.
> > -- Kurt Vonnegut
> >
> I believe %5C is the http code for %.
>
> Are you saying then that FCKEditor is sending the %20 encoded URL when
> you submit the form? I've not had any problems using FCKEditor myself.
> Have you tried using str_replace('%20', ' ', $url) on the URL when you
> receive it from the form?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
Actually, %5C is a \ character, % is %25
Why it is adding a character that is used in local address strings is
baffling and I think a clue as to what is going on. Is it possible it is
mashing a local file address into a web address?
BTW, IMHO using spaces in folder and/or file names is bad practice and
should be avoided.
Marc Hall
HallMarc Websites
610.446.3346
__________ Information from ESET Smart Security, version of virus signature
database 4403 (20090907) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Displaying image paths with spaces
am 07.09.2009 21:46:47 von Skip Evans
HallMarc Websites wrote:
> Actually, %5C is a \ character, % is %25
> Why it is adding a character that is used in local address strings is
> baffling and I think a clue as to what is going on. Is it possible it is
> mashing a local file address into a web address?
Aha! I think that might be it. In the database it is stored as
src="/clients/client_118/images//Event%20images/Show%20ads/c atspaw1compressed.jpg"
But somehow it is converting this to a local file address
before it is displayed.
>
> BTW, IMHO using spaces in folder and/or file names is bad practice and
> should be avoided.
I totally agree and the code I write I always replace user's
spaces with '_' characters, but this is FCKeditor's directory
creation code.
Maybe I should look into modifying it to do the same. I
actually have already modified FCK to store images in client
specific directories and found the code to be pretty well
written so maybe I need to do the same and solve the problem
that way.
I'll check that out.
Thanks Ash and Marc for the input. I think we're on the right
path ;)
Skip
--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Displaying image paths with spaces
am 08.09.2009 15:48:20 von Bob McConnell
From: Skip Evans
> HallMarc Websites wrote:
>> Actually, %5C is a \ character, % is %25=20
>> Why it is adding a character that is used in local address strings is
>> baffling and I think a clue as to what is going on. Is it possible it
is
>> mashing a local file address into a web address?=20
>=20
> Aha! I think that might be it. In the database it is stored as
>=20
>
src=3D"/clients/client_118/images//Event%20images/Show%20ads /catspaw1comp=
r
essed.jpg"
>=20
> But somehow it is converting this to a local file address=20
> before it is displayed.
That's the job of the browser. It takes those entities and converts them
to displayable characters. You might want to look at the htmlentities()
and related functions to put it back into the encoded version.
Bob McConnell
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php