View Single Post
  #11 (permalink)  
Old 06-07-2008, 01:06 PM
Hrimthurs Hrimthurs is offline
Newbie
 
Join Date: Jan 2008
Posts: 8
Credits: 0
Rep Power: 0
Hrimthurs is on a distinguished road
Default Re: Create files with php

I use this code, and find it works on my server at PHP Version 4.4.8

PHP Code:
<?
$url 
$_REQUEST['url'];

if (
$url != ''){
$file = isset($_POST['file']) ? $_POST['file']:$url;
$data $_REQUEST['data'];
$newfile fopen($file"w+") or die ("could not create file.");
fclose($newfile);
$myfile = @fopen($file"w+") or die ("could not open file.");
@
fwrite($myfile$data) or die ("could not write to file");
fclose($myfile);
$msg "<p>File created: <a href='$file'>$file</a><br/>Content:<br>$data</p>";
echo 
$msg;}
else {echo 
'<form action="?create=go" method="post" name="new">
File name.extention: 
<input name="url" type="text" size="30" maxlength="60" /><br/>
File data: 
<textarea name="data" size="30" id="data" ></textarea><br/>
<input name="" type="submit" value="CREATE FILE" /></form>'
;}
?>
Reply With Quote