Howdy,Just to understand what you are trying to do: A user uploads a file.If it is of an accepted type, you want to generate a unique name and rename it.That correct?

justlukeyou
—
2012-10-29T11:21:51Z —
#3

Hi mate,

Its for an image upload, currently it only uploads one image and calls it image.png

I am trying to make it so it uploads infinite images each with a unique number.

Pullo
—
2012-10-29T11:56:52Z —
#4

Could you not then generate a unique file name based on the user's IP address and the current time stamp?Something like:

$n = time() . $_SERVER['REMOTE_ADDR'] . $ext;

cpradio
—
2012-10-29T12:18:31Z —
#5

The error in your code is because you have $n = "uniqid().$ext"; instead of $n = uniqid().".$ext";

justlukeyou
—
2012-10-29T19:44:21Z —
#6

cpradio said:

The error in your code is because you have $n = "uniqid().$ext"; instead of $n = uniqid().".$ext";

Brilliant, thanks everyone. That worked straight away.

KyleWolfe
—
2012-10-29T20:14:34Z —
#7

Just curious... If you try uploading a file type not in your case statement, does it error out saying nothing was uploaded, or does it try to go through the logic anyway? I ask because I thought that if($ext) check to see if it is set, while you would be setting an empty string to $ext.