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

What you exactly want?
Does your posted code works? even partially?
And where is html portion?

use [$p] not

or use /upload
and make some folders by month in each year by function mkdir
same
uploads/2010/8/18/logo.jpg
2.use insert into history inside of if move_uploaded
3.try sql insert into history(field1,field2,fiels3) VALUES('".$val1."','".$val2"' .............
4.test uploaded file by file exists befor creat log in history

make sure file names nothaving "/" or "#" by str_replace
$bad_keys=array("#","/","?","~");
$rep_keys=array("","","","");
$file_name=str_replace($bad_keys,$rep_keys,$file_name);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.