473,233 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

Having trouble with spaces

BJB
I am trying to get my php script to display an image from a directory from
other than the webservers root directory
This doesnt work:

header('Content-Type: image/jpg');
readfile("/blah/foo bar/pic.jpg");

But this does:

header('Content-Type: image/jpg');
readfile("/blah/pic.jpg");
I am guessing it is the space that is messing it up. I tried to escape the
spaces with '\' like in Linux or %20 but they dont seem to help. I dont
want to have to change the space to something like an underscore becasue
then I'd have to change about 300 directories. Is there anyway to make this
work?

If anyone has any ideas I would greaty appreciate them.
Jul 17 '05 #1
5 4362
"BJB" <bl**@spamsucks.com> wrote in message
news:l%**********************@newssvr28.news.prodi gy.com...
I am trying to get my php script to display an image from a directory from
other than the webservers root directory
This doesnt work:

header('Content-Type: image/jpg');
readfile("/blah/foo bar/pic.jpg");

But this does:

header('Content-Type: image/jpg');
readfile("/blah/pic.jpg");
I am guessing it is the space that is messing it up. I tried to escape the spaces with '\' like in Linux or %20 but they dont seem to help. I dont
want to have to change the space to something like an underscore becasue
then I'd have to change about 300 directories. Is there anyway to make this work?

If anyone has any ideas I would greaty appreciate them.


try this: header('Content-Type: image/jpg');
readfile("\"/blah/foo bar/pic.jpg\"");

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
BJB wrote:
I am trying to get my php script to display an image from a directory from
other than the webservers root directory
This doesnt work:

header('Content-Type: image/jpg');
readfile("/blah/foo bar/pic.jpg"); If anyone has any ideas I would greaty appreciate them.


Works on my computer: PHP 4.3.3 on Linux

Try this:

#v+
<?php
$filename = '/blah/foo bar/pic.jpg';

if (isfile($filename) {
if (is_readable($filename) {
header('Content-Type: image/jpg');
readfile($filename);
} else exit($filename . ' is not readable.');
} else exit($filename . ' is an invalid file.');
?>
#v-

I'm betting your problem is _not_ the space :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Hmmm...are you sure "foo" and "bar" are not separated by two spaces? Or
perhaps someone is playing a joke on your and the space is actually a \xA0?
There's no reason why the code isn't working.

Uzytkownik "BJB" <bl**@spamsucks.com> napisal w wiadomosci
news:l%**********************@newssvr28.news.prodi gy.com...
I am trying to get my php script to display an image from a directory from
other than the webservers root directory
This doesnt work:

header('Content-Type: image/jpg');
readfile("/blah/foo bar/pic.jpg");

But this does:

header('Content-Type: image/jpg');
readfile("/blah/pic.jpg");
I am guessing it is the space that is messing it up. I tried to escape the spaces with '\' like in Linux or %20 but they dont seem to help. I dont
want to have to change the space to something like an underscore becasue
then I'd have to change about 300 directories. Is there anyway to make this work?

If anyone has any ideas I would greaty appreciate them.

Jul 17 '05 #4
On Thu, 08 Jan 2004 19:15:29 +0000, BJB wrote:
I am guessing it is the space that is messing it up. I tried to escape the
spaces with '\' like in Linux or %20 but they dont seem to help. I dont
want to have to change the space to something like an underscore becasue
then I'd have to change about 300 directories. Is there anyway to make this
work?


although spaces *shouldn't* be a problem, technically, the
reality is that they are and can be a problem. You'll be far better off
in the long run to get in the habit of not using spaces in filenames.

Trust me on that one. I promise that spaces in filenames will be a problem
if you keep using them.

A "for i in *" shell loop can change the filenames quite easily. (if you
know a small amount of shell scripting, and you should at least a little.
it's good for you.)

Or a quickie perl script will do the same.

later...

--
-------------------------
| Jeffrey Silverman |
| jeffrey-AT-jhu-DOT-edu|
-------------------------

Jul 17 '05 #5
BJB
> I'm betting your problem is _not_ the space :)
I think you were right. Not sure what I was doing wrong but after tinkering
with it for a little while it is working.

Thanks everyone for the help.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: M | last post by:
Hi Folks, I am trying to install Smarty using PHP 5 on a Windows XP PC using IIS v6 The following PHP File: <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head>
3
by: Ian Arnold | last post by:
Alright, so I know that you can use char pointers to store strings, and I'm trying to make a very simple program to see how it all works that will have the user enter 5 characters, then the...
11
by: 2D Rick | last post by:
I need help getting this syntax to work. I want to open a form to a specific record based on dual criteria. Both fields are text fields as is the input. I get an error message "type mismatch" ...
5
by: Mike Labosh | last post by:
Can someone provide a link to something a bit more useful than the MSDN topics? -- Peace & happy computing, Mike Labosh, MCSD "Musha ring dum a doo dum a da!" -- James Hetfield
1
by: tshad | last post by:
Some of my regular expressions don't seem to work correctly in IE7. I am on asp.net 1.1. I have a site that has been up for a while and I started having problems on machines with IE7. IE5 and...
2
by: massdeletion101 | last post by:
I'm trying to write a string I entered into the program to a file. I won't explain it though, it's probably easier if I just post the code: #include <iostream> #include <fstream> #include...
0
by: Scott M. | last post by:
Hi, Can anyone tell me why my query doesn't work? I have a table called ECO Main with columns ECO Number and ECO Revision. I can see the data in my form, and I created a Delete Record button...
1
by: ghjk | last post by:
I want to split a string which not having spaces or etc. Ex:START44.98. It always having "START" and values is different.ex:00.00, 000.00,0.00. I want to take only the numeric value. How can i do...
2
by: shweta khare | last post by:
basically we observed that in order to input 2 character constants at a time we ought to give spaces....hav a peek in ter dis.... case1 void main( ) { char a,b; printf("\n enter...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.