/    Sign up×
Community /Pin to ProfileBookmark

PhP cannot create file, windows problem?

Hi folks,

I have this class, and it really works for exisiting files (editing them),
but as soon as i want to create a new File with that class i get an error, that i cannot open this file.

In normal case, this file should just be created, when not found …

I run PhP under windows and apache. And i dont get it, why it doesn’t work.

[CODE]class CFile
{
private $filename;
private $handle;

public function __construct($sFileName)
{
$this->fileName = $sFileName;
//$this->filename = “test.xml”; //works, because test.xml exists
if (!$this->handle = fopen($this->filename, ‘wb+’)) throw new Exception(“Could not open File “.$this->filename);
}
public function __destruct()
{
fclose($this->handle);
}

//will be done automatically, because file is opened with w+
public function ClearFile()
{
}

public function Write($data)
{
// Write $somecontent to our opened file.
if (fwrite($this->handle, $data) === FALSE)
{
throw new Exception(‘Could not write Data $data.’);
}
}
};[/CODE]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Ben2008authorAug 19.2008 — Sorry i am too stupid ...

i searched that bug for hours ..

$this->fileName = $sFileName;

//$this->filename = "test.xml";

This is case sensitive and the first one is called fileName ... but thats wrong ?
×

Success!

Help @Ben2008 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...