Generating sequence number (for filename)

Got another issue…

I’ve made a form that allows users to upload images to the webserver and then stores the URL in a database to be recovered later (to show images on a page).

The code i’m using generates a random number for the filename, but the trouble is that since it’s random, it sometimes overwrites an existing file on the server when you upload a new one, messing it all up.

How can I get it to generate a sequence number on upload, rather than a random?

I’m using this code to generate the random number:

$rand= rand(0, 1000);
$image_nameA=$rand.'.'.$extension;

Thanks! :slight_smile: