Dynamic folder/file creation? Script help...
Posted: Thu Nov 11, 2004 4:52 am
I can't seem to figure out how to create a dynamically-named folder/file on my server... I get a "failed to open stream: No such file or directory" warning... I kinda assumed that would happen. Does anyone have any suggestions? I am also curious to hear peoples thoughts on making the below script secure:
Any help would be greatly appreciated.
Thanks!
Cheers
m
Code: Select all
<?php
echo "<form action='".$_SERVER['PHP_SELF']."?action=create_quote' method='post' name='create_quote_now'>"."\n";
print <<< PRINT_PAGE
Company: <input name="company" type="text" value="Company" size="15" maxlength="40">
<input name="submit" type="submit" value="Submit">
</form>
PRINT_PAGE;
if ($_GET['action'] == "create_quote") { // If user donated money:
$html="<head><title>Quote for $company</title></head>\n
This is a quote for $company";
//generate file name
$qfname = $company . '_quote';
//open file
$fp=fopen('./$company/$qfname.html','wb');
fwrite($fp,$html);
fclose($fp);
echo "your file has been created, <a href='./$company/$qfname.html'>click here</a> to scope it!";
}
?>Thanks!
Cheers
m