1

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>
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by rana.moeen
0

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();
	}
?>
0

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

post_max_size

in

php.ini

file..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.