Okay, I am fairly new to PHP…
I am looking how to create a .PHP document with a md5 name. I already have a script to it, but I cant figure out how to make it. I have it set to write the document created, just I cant figure out how to create it and have it uploaded to my server. Heres what I have:
<?php
$submit = $_POST['submit'];
if ($submit)
{
$newName = 'test/' . substr(md5(rand() . time()), 0, 20) . '.php';
$tf = fopen($newName, 'w');
fwrite($fp, '<html><head><title>Hello</title></head><body><p>Hello People!</p></body></html>');
fclose($tf);
move_uploaded_file($_FILES['imagedata']['tmp_name'], $newName);
// Website
echo 'http://www.linkremoved.com/' . $newName;
}
else
{
echo "<form action='md5createtest1.php' method='post'><input type='submit' value='Submit' name='submit' /></form>";
}
?>
But after I try it… I get this error:
Warning: fopen(test/5ac397dc440982c9e63b.php) [function.fopen]: failed to open stream: No such file or directory in /home/removed/public_html/test/md5createtest1.php on line 8
Warning: fwrite(): supplied argument is not a valid stream resource in /home/removed/public_html/test/md5createtest1.php on line 9
Warning: fclose(): supplied argument is not a valid stream resource in /home/removed/public_html/test/md5createtest1.php on line 10
http://www.linkremoved.com/test/5ac397dc440982c9e63b.php
Any help?
What’s opened with fopen needs to match what’s in fwrite().