LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-13-2004, 09:04 PM   #1
gw1500se
Member
 
Registered: Mar 2004
Distribution: Mandriva 2010.0
Posts: 220

Rep: Reputation: 30
Handling filenames with spaces in PHP


I have some PHP pages that worked fine using a Windows based HTTP server (specifically OpenSA - Apache). I have since moved those pages to a Mandrake 9.2 system. The problem is that referencing filenames with imbedded spaces worked fine under Windows. However, in Unix those imbedded spaces cause errors. I can use quotes (") on the command line to access those filenames but that doesn't seem to work with the Mandrake version of PHP.

For example, what would be the corrrect syntax of:

if (file_exists($dirname."/".$filename.".txt")) {

if both of the strings in $dirname and $filename contain spaces?

I tried this to no avail:

if (file_exists("\"".$dirname."/".$filename.".txt"."\"")) {

TIA.
 
Old 03-14-2004, 05:38 AM   #2
miyake
LQ Newbie
 
Registered: Nov 2003
Location: Socal
Distribution: Slackware, RedHat
Posts: 13

Rep: Reputation: 0
Did you try backslash in front of the space? For example...

$ cd "folder name"
$ cd folder\ name

Test it with the Mandrake version of php. If it works, just use str_replace or any similar functions to turn spaces into backslash spaces.
 
Old 03-14-2004, 01:03 PM   #3
gw1500se
Member
 
Registered: Mar 2004
Distribution: Mandriva 2010.0
Posts: 220

Original Poster
Rep: Reputation: 30
No I didn't. Thanks for the suggestion.'ll give it a try.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
filenames with spaces antony.booth Programming 5 11-01-2005 04:49 AM
ls and filenames with spaces rose_bud4201 Programming 10 07-01-2005 08:28 AM
Spaces in filenames with mpg123 Boffy Linux - Software 3 04-26-2004 02:51 PM
filenames with spaces - explain t3___ Linux - Newbie 14 02-17-2004 06:13 PM
spaces in filenames ebone Linux - General 2 11-12-2001 11:56 AM


All times are GMT -5. The time now is 04:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration