Zmienianie nazw plików

Zainstalowałem na serwerze skrypt uploadu pików, ale po wysłaniu pliku na serwer zmienia on jego nazwę przez co gdy plik jest podzielony na kilka części nie można go rozpakować, ponieważ w każdym pliku trzeba by zmienić nazwę.

Proszę o pomoc, ponieważ nie umiem tego zrobić. Najlepiej aby skrypt dodawał do nazwy np. na początku kilka numerków aby się nie powtarzały na serwerze.

Plik upload.php skryptu:

<?

	include("include/common.php");

	include("include/header.php");

	if($loggedin){

		include("include/accmenu.php");

	}

	if( $_POST['submit'] && $_FILES['attached']['name'] ){

		$ok_filetypes = explode("|",$att_filetypes);

		if (!$_FILES['attached']['error'] && $_FILES['attached']['size'] > $att_max_size*1024){

			errform('Sorry, but the attached file is too large. Please reduce the size of it\'s contents.'); // #err

			$step = 1;

		}

		$filename = (!$_FILES['attached']['error'] ? substr( basename($_FILES['attached']['name']), -30 ) : '');

		$x = strtolower( substr($_FILES['attached']['name'], -3));

		if($filename && !in_array($x, $ok_filetypes) ){

			errform('Sorry, the filetype you have tried to upload is not allowed.');

			$step = 1;

		}

		if(!$posterr){

			if(!isset($_GET["ipaddress"]) || ($_GET["ipaddress"] == "")) {

				$ipaddress = $_SERVER['REMOTE_ADDR'];

				$local = 1;

			} else {

				$ipaddress = $_GET["ipaddress"];

				$local = 0;

			}

			$uniq = substr( md5(uniqid (rand())), 0, 10 );

			$ext = strtolower( substr($_FILES['attached']['name'], -3));

			move_uploaded_file($_FILES['attached']['tmp_name'], $att_path."/".$uniq.".".$ext );

			$strQuery = "INSERT INTO images SET ";

			$strQuery .= "filename='".$uniq.".".$ext."',";

			$strQuery .= "ipaddress='{$ipaddress}',";

			$strQuery .= "date='".time()."',";

			$strQuery .= "pkey='{$uniq}',";

			if($myuid){

				$strQuery .= "user='{$myuid}',";

			}

			$strQuery .= "status='1'";

			$result = mysql_query($strQuery) or die( mysql_error() );

			$aid = mysql_insert_id();

			if($aid){

				$filen = $siteurl."/".str_replace('./', '', $att_path)."/".$uniq.".".$ext;

				$filen = str_replace('http://','%%',$filen);

				$filen = str_replace('//','/',$filen);

				$filen = str_replace('%%','http://',$filen);

				$step = 2;

			}else{

				$step = 1;

			}

		}

	}else{

		$step = 1;

	}

	if($step == 1){

?>

|
File extensions allowed: <?=implode(", “,explode(”|",$att_filetypes))?> File size limit: <?=$att_max_size?>KB
|

<? }else{ ?> Twoj plik zostal wyslany!

|

|
|
Jezeli jest to obrazek i chcesz wkleic go do wiadomosci email skorzystaj z ponizszego kodu: [img=?=$filen?]
|
|
LINK DO TWOJEGO PLIKU: ?=$filen?
|
|
Jezeli jest to obrazek i chcesz go uzyc na stronie, forum itp. uzyj kodu HTML. Wklej ponizszy kod:
|
|   |
? } ? ? include(“include/footer.php”); ?[/code]