...

View Full Version : Creating a directory...



Taylor_1978
01-15-2004, 11:50 AM
Can someone please point me in the right direction of where I can read up on how to create a directory on my website using PHP!

Thanks in advance :thumbsup:

Taylor.

Taylor_1978
01-15-2004, 12:10 PM
Okay - change that - I know how to create a directory now.. However I wanted to create a index.php file in the directory - but it wont do it - it just creates the directory - all I see in examples that I have read is how to create a .txt file - but I want a .php file WAAAA! lol

Any help would be greatly appreciated!

Thanks in advance! :thumbsup:

Taylor.

Nightfire
01-15-2004, 03:50 PM
Just change the extension in the txt file script to file.php instead of file.txt

Taylor_1978
01-16-2004, 01:17 AM
It wont work - it only creates a .txt not .php - let me show ya:

<? $res_dir = "../$url";
$res_file = $res_dir."/index.php";

if (!file_exists ($res_file))
{
if (!mkdir ($res_dir, 0700)) die ("Server Error: Can't create directory");

$content = "\<\? include (\"http://ysuperleague.com/system?url=$url\"); \?\>";
$handler = fopen ($res_file, "w");
fwrite ($handler, $content);
fclose ($handler);
print " CREATED !!!!!!!!";
}

?>

It creates the directory but does not create the index.php file.

DsgnrsTLZAdmin
01-16-2004, 02:11 AM
<?php
$makefile = fopen("index.php", "a+");
fclose($makefile);
?>




what this does is try to open a file named "index.php". it uses the access mode a+ which creates the file if it doesnt exist which is doesnt so it makes a file called "index.php". :):)

Taylor_1978
01-16-2004, 03:18 AM
Okay _ tried this but still not making file - Can you possibly add what you are suggesting into my own code as I am obviously writing it wrong!

<? $res_dir = "../$url";
$res_file = $res_dir."/index.php";

if (!file_exists ($res_file))
{
if (!mkdir ($res_dir, 0700)) die ("Server Error: Can't create directory");

$content = "\<\? include (\"http://ysuperleague.com/system?url=$url\"); \?\>";
fopen ($res_file, "a+");
$handler = fwrite ($res_file, $content);
fclose ($handler);
print " CREATED !!!!!!!!";
}


?>
Thanks in advance :thumbsup:

Nightfire
01-16-2004, 01:00 PM
<?php

$res_dir = "../$url";

$res_file = $res_dir."/index.php";

if (!file_exists ($res_file))
{
if (!mkdir ($res_dir, 0700)) die ("Server Error: Can't create directory");

$content = "\<\? include (\"http://ysuperleague.com/system?url=$url\"); \?\>";
$openfile = fopen ($res_file, "a+");
fwrite ($openfile, $content);
fclose ($openfile);
print " CREATED !!!!!!!!";
}

Taylor_1978
01-18-2004, 12:52 PM
Okay - I found the problem and it turns out it is not a script error!

The script was creating the directory but would not create the file... I tried over and over. Then, I tried to manually save a file in that directory and it stated that there was a system error... So basically - any directory made via the !mkdir would not allow any files to be stored in it... via fopen or manually... Any ideas as to why?

Thanks in advance :thumbsup:
Taylor.

firepages
01-18-2004, 04:00 PM
try ...


<?
mkdir ($res_dir, 0777);
fputs(fopen($res_dir.'/test.txt','w'),'test');
chmod($res_dir ,0755);
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum