473,408 Members | 2,441 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,408 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 4369
"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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.