Page 1 of 1

Creating File to SPECIFIC directory

Posted: Sun Nov 21, 2004 4:20 pm
by genetix
I'm creating a file manager but I cant figure out how to get this code block to work. Its to create a file in the users folder.

The page is created. Its just in the same dirrectory of the script.

$file = files name ex. index.php
$username = logged in user only consisting of letters
$wdpage = variable with information saying like page coming soon.

Code: Select all

$filefull = "C:/AppServ/www/hosting/$username/$file";
$handle = fopen("$file", "a");
fwrite($handle, $wdpage);
fclose($handle);

Posted: Sun Nov 21, 2004 4:38 pm
by peni
look for the premissions and try to escape the backslashes:

Code: Select all

$filefull = "C:\\AppServ\\www\\hosting\\$username\\$file";

Posted: Sun Nov 21, 2004 5:46 pm
by rehfeld
look at the fopen call....

your creating the file named $file
you need to create $filefull

btw- peni, at least win xp,
C:\foo\file

has never been any diff than

C:/foo/file


for me

ive never had an issue when not using win style backslashes as dir seperators

Posted: Sun Nov 21, 2004 6:00 pm
by peni
very true.

Posted: Sun Nov 21, 2004 6:48 pm
by genetix
I fixed the error where $file should have been $filefull but it still doesn't work. Heres the errors:

Warning: fopen(C:/AppServ/www/hosting/WebDummy/works.php): failed to open stream: No such file or directory in c:\appserv\www\webdummy\www\serverpro\page_create.php on line 95

Warning: fwrite(): supplied argument is not a valid stream resource in c:\appserv\www\webdummy\www\serverpro\page_create.php on line 96

Warning: fclose(): supplied argument is not a valid stream resource in c:\appserv\www\webdummy\www\serverpro\page_create.php on line 97

oh ya and I thought I would add. The server is running on Windows XP.

Posted: Mon Nov 22, 2004 1:29 am
by rehfeld
if your trying to create the file:

C:/AppServ/www/hosting/WebDummy/works.php

make sure that this exists and is writable

C:/AppServ/www/hosting/WebDummy/

fopen cannot create directories

Posted: Tue Nov 23, 2004 5:45 pm
by genetix
Thanks, I got it working again. The problem was that Web Dummy is my site so I had it setup in a local folder instead of hosting. I was trying to save to a dirrectory that didn't exist :oops:


Thanks again.