-1

Here is my code

$file = 'post.php';
$root = '/' . $dir_auth1 . '/'. $file;
$folder = mkdir(rand(10,10000)); 
$folder5 = $folder . '/' . $file;
echo $folder5;
if($folder) {

if (!copy($root, $folder5)) {
        echo "failed to copy $file...\n";

} else {
    echo "<p style='font-size:35px;font-family:verdana;text-align:center;'>status was successfuly created.</p>";
}


} 

Basically what I am trying to do is upon a form submit create a directory with random digits and place the $file variable inside of the randomized directory

aidangig
  • 199
  • 1
  • 12

1 Answers1

0

mkdir - return bool. Please read about mkdir

And rewrite you code something like this:

$file = 'post.php';
$root = '/' . $dir_auth1 . '/'. $file;
$folder = rand(10,10000);
mkdir($folder); 
$folder5 = $folder . '/' . $file;

And check you if. You always true. (not empty string = true)

Maxim Tkach
  • 1,607
  • 12
  • 23
  • thank you So I want the created directory with random digits to have the file stuffed inside of it, not have it return 1. – aidangig Jul 08 '16 at 07:35
  • mkdir($dir); at that line of code what is the $dir, variable? What are you referring to? Its not in mine. – aidangig Jul 08 '16 at 07:37
  • It won't copy because it is still returning one, when the page loads. I have it echo $folder and $folder5. Still says 1. – aidangig Jul 08 '16 at 14:45