Hi. I'm using rand() or mt_rand() to give a temporary file i upload a random name so that i can work with it.
However the file always gets the same name, resulting in overwriting a previous uploaded file.
These 2 functions aren't supposed to return a random value?

rand() returns 2
mt_rand() returns 1755202938

Why am i getting the same number all the time?
Thanks

John

    Ha ha ha ha ......

    Something sounds seriously wrong. Why don't you let us see some code so that we can begin to figure it out.

    Cheers,
    BDKR

      you need to give rand() something to random

      like

      $number = rand(6,9); // this will random between 6 and 9

      if you need a 8 digit number or "Filename"

      why not just do this...

      $filename = rand(10000000, 300000000);

      though I dont think this is really what your looking for

        $tmp = rand();

        $image_name = $tmp.$extension;

        simple 🙂

          I tried it Digital.
          I still get a fixed number

            Originally posted by johnie
            I tried it Digital.
            I still get a fixed number

            are you use a random generator with it also?

            srand((double)microtime()*1000000);

              check out this site

              http://rbcode.com/test.php

              now refresh it.. you should get diffrent numbers...here is the code

              <?
              srand((double)microtime()*1000000);
              $filename = rand(10000000, 300000000);
              echo "$filename";
              ?>

                Write a Reply...