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.

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

Recommended Answers

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

Jump to Post

All 3 Replies

Member Avatar

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

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

Sorry for that.

	$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);
		echo 'Files uploaded successfully ';
		echo 'Error: please try again, <br />' . mysql_error();

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





Be a part of the DaniWeb community

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