What I want is upload an image, get unique ID and save this in server. I have two methods to get ID and I want to know if this is the right path for real application.
method 1
round(microtime(true));
method 2
md5(uniqid(rand(), true));
UPDATE: Use cryptographic-ally unique id - uuidV4 to gaureente uniqueness
https://stackoverflow.com/a/31460273/3359432
You can use PHP inbuilt function uniqid
. Available since PHP 4
Quoting from PHP official site
<?php
/* A uniqid, like: 4b3403665fea6 */
printf("uniqid(): %s\r\n", uniqid());
/* We can also prefix the uniqid, this the same as
* doing:
*
* $uniqid = $prefix . uniqid();
* $uniqid = uniqid($prefix);
*/
printf("uniqid('php_'): %s\r\n", uniqid('php_'));
/* We can also activate the more_entropy parameter, which is
* required on some systems, like Cygwin. This makes uniqid()
* produce a value like: 4b340550242239.64159797
*/
printf("uniqid('', true): %s\r\n", uniqid('', true));
?>
http://php.net/manual/en/function.uniqid.php
You must also read the warning
Warning This function does not guarantee uniqueness of return value. Since most systems adjust system clock by NTP or like, system time is changed constantly. Therefore, it is possible that this function does not return unique ID for the process/thread. Use more_entropy to increase likelihood of uniqueness.
Yes Sure You Can Use Md5 with current date and time