note 49888 deleted from function.mkdir by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 18:13:53 +0000 |
| Subject: | note 49888 deleted from function.mkdir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133263@lists.php.net to get a copy of this message | ||
Note Submitter: par dot sandgren at gmail dot com
----
You might want to upload files into random named dir's, just to make it harder to guess the
link. But still have some ID to know whats in there.
<?php
$dirLength = rand(30, 40);
$projectID = $_POST['pid']; // ID from database perhaps?
$rndName = "";
for($i=0; $i<$dirLength; $i++)
{
$rnd = rand(1, 3);
if($rnd == 1)
$rndName = $rndName . chr(rand(97, 122));
else if($rnd == 2)
$rndName = $rndName . chr(rand(65, 90));
else
$rndName = $rndName . chr(rand(48, 57));
}
$dirName = $projectID . "-" . $rndName;
mkdir($dirname);
?>