PHP Script Number Generator and .txt creator?

Terrum

New member
I am quite a PHP noob and willing to learn.

I need a script what will have a button on a page what creates a text document file in a specific folder of the web server, And a code generator what randomally generates a code of numbers and letters (about a length of 5 or 6), And the generated code will be the name of the .txt file. (e.g: The php generates random numbers and letters, it goes onto the name of the .txt file - 9ti14a.txt) And inside the .txt file will just have the numbers "500". Then when the code is generated and the file is created, The screen will echo the generated code.

I hope someone can help,
Thanks.
 
<?php
$file_realname = trim($_FILES['Filedata']['name']);
$uploaddir = 'uploads/';

$ext = substr(strrchr($file_realname,'.'),1);
$new_name = md5(uniqid(rand(), true));
$new_file = sprintf ("%s.%s", $new_name, $ext);

if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploaddir . $new_file)) {
echo $new_file;
} else {
print "<strong>$file_realname</strong> did not upload!";
}

Not eactly what you want - and the random number generator thing just might do you what you want.. so instead of md5'ing it.. you might just want:

uniqid(rand(), true)
 
Back
Top