I have no problem uploading files - but I can not seem to issue them a name at the same time. I want to create a name using the existing name plus a rand number but keeping the extension ie. .jpg .exe .bmp
Can somebody please help me with this? Here is the code I am using:
<?
if($submit) {
/upload.php/
$max_size = " 1000000 ";
if ($img1_name != "") {
if($img1_size > $max_size) {
echo "File size is bigger than $max_size bytes!";
exit;
}
@copy("$img1", "../uploads/$img1_name")
or die("No copy!");
?>
<HTML>
<HEAD>
<TITLE>Uploaded</TITLE>
</HEAD>
<BODY>
<P>File name<? echo "$img1_name"; ?>, <br> File Size <? echo "$img1_size"; ?> bytes <br>
File Type <? echo "$img1_type"; ?>.</P>
</BODY>
</HTML> <?
} else {
die("No input file!");
}
} else {
?>
<HTML>
<HEAD>
<TITLE>Upload</TITLE>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="upload.php" ENCTYPE="multipart/form-data">
<p><strong>File</strong><br>
<INPUT TYPE="file" NAME="img1" SIZE="30"></p>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Send"></p>
</FORM>
</BODY>
</HTML>
<? } ?>
Thank You!