Hi Geeks, Here is code below, I wrote for multi file upload. This form takes a numeric value from previous page and print required form fields on this page. But when I write php code for upload it gives me errors. I use print_r($_FILES); but it returns an empty array(). Please help me how can I process this multi file form and store it into database. Give me php code for this form.

<?php
	$fileValue = $_POST['field'];
?>
<body>
<form action="final.php" method="post" enctype="multipart/form-data" name="final">
    <input name="total" type="hidden" value="<?php echo $fileValue; ?>"  />
    <?php 
    for($counter = 1; $counter <= $fileValue; $counter++){
    ?>
    Song Name:
    <input type="text" name="song_name[]" /><br />	
    Artist:
    <input type="text" name="artist[]" /><br />
    File: 
    <input type="file" name="file[]" /><br />
    <?php
    	}
    ?>
    <input type="submit" name="submit" value="Submit" />
</form>
Member Avatar for diafol

You don't show any of your file uploading code...

You don't show any of your file uploading code...

Sorry for that.

<?php 
	mysql_connect("localhost","root","");
	mysql_select_db("multi_upload");
	
	$path = "./upload_data/";
	$uniq = "musicfun";
	$total = $_POST['total'];
	for($c = 0; $c <= $total; $c++){
	$uniq_name = $uniqid .'_'. $_FILES['file'][$c]['name'];

	$complete_path = $path . $uniq_name;

	$copy = move_uploaded_file($_FILES['file'][$c]['tmp_name'], $complete_path);
	
	$query = "INSERT INTO songs SET
		song_name = '".$_POST[$c]['song_name']."',
		artist = '".$_POST[$c]['artist']."',
		path = '".$uniq_name."' ";
	
	$exe = mysql_query($query);
	}
 	if($exe){
		echo 'Files uploaded successfully ';
	}else{
		echo 'Error: please try again, <br />' . mysql_error();
	}
?>

I find the solution for my problem above myself. The problem is solved by increasing

post_max_size

in

php.ini

file..

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.