i have uploaded a group of files and the number of files uploaded is dynamic its value is recieved from form now the name of file type is the number of attachment e.g if 2 files are uploaded then name of 1st file in form will be 1 and name of second file will be 2 so on and so for.i have written the following code
$num=$_POST['num'];
$date=date('Y-m-d');
$query="INSERT INTO `complaint` VALUES (NULL , '$name', '$ph_no', '$contact_no', '$type','$date', '$sent_to', '$sent_by')";
mysql_query($query) or die("error in insertion query");
$q="SELECT LAST_INSERT_ID() as last";
$r=mysql_query($q);
$p=mysql_result($r,0,"last");
$target = "upload/";
$i=1;
while($i<=$num)
{
$target = $target .date('Y-m-d')."_".$p. "_".$i;
if(move_uploaded_file($_FILES['$p']['tmp_name'], $target)){echo "hello";
$img=date('Y-m-d').time('H:m:s').$p. "_".$i;echo $img;}
$query2="INSERT INTO `history` VALUES ($p, '$img' , '$detail' , '$date', '$sent_to', '$sent_by', '$status')";
mysql_query($query2) or die ("ERRor in insertion query");
echo " your data has been inserted";
$i++;
}
hoping for reply soon
regards,
:)shivaniaroraji