Hello all,

First my english sucks, but I don't think you all can read dutch

OK, i'm busy making a site for a audiovisual company and i'm stuck at the CMS system by adding pictures to a project page.

Adding one single photo isn't the problem but I want a button to add a new file input field and insert that second (or thirth, fourth etc etc) into a new row in the database....

The script that i'm using right now, clones the input field but doesn't "activates" it.... You can't select a file....

The javascript:
function clone() {
		var parent=document.getElementById('naw0');
		var cloned=parent.cloneNode(true);
		// unique id
		var aNaam=document.getElementsByName('imgfile[]');
		var num=aNaam.length;
		//insert after last pair
		parent.parentNode.insertBefore(cloned, document.getElementById('naw'+(num-1)).nextSibling);
		//clear inputs
		var aInput=cloned.parentNode.getElementsByTagName("file");

and the HTML/PHP code:

PHP Code:
if (isset($_REQUEST['submit'])) { 
$name $_POST["name"];
$description $_POST["description"];
$video $_POST["video"];
    for (
$i=0$i count($Naam); $i++)
//foto uploaden
$path_thumbs "upload/thumbs";
$path_big "upload/images";
//the new width of the resized image.
$img_thumb_width 150// in pixel
            //Do you want to limit the extensions of files uploaded (yes/no)
$extlimit "no"
//allowed Extensions
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp");
$file_type $_FILES['imgfile[]']['type'];
$file_name $_FILES['imgfile[]']['name'];
$file_size $_FILES['imgfile[]']['size'];
$file_tmp $_FILES['imgfile[]']['tmp_name'];
//check file extension
$ext strrchr($file_name,'.');
$ext strtolower($ext);
           if ((
$extlimit == "yes") && (!in_array($ext,$limitedext))) {
"Verkeerde extensie.  <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
//get the file extension.
           //$getExt = explode ('.', $file_name);
           //$file_ext = $getExt[count($getExt)-1];
$file_ext end(explode("."$file_name));
//create a random file name
$rand_name md5(time());
//get the new width variable.
$ThumbWidth $img_thumb_width;
//keep image type
$file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img imagecreatefromjpeg($file_tmp);
$file_type == "image/x-png" || $file_type == "image/png"){
$new_img imagecreatefrompng($file_tmp);
$file_type == "image/gif"){
$new_img imagecreatefromgif($file_tmp);
//list width and height and keep height ratio.
list($width$height) = getimagesize($file_tmp);
               if (
$newwidth $ThumbWidth;
$newheight $ThumbWidth/$imgratio;
$newheight $ThumbWidth;
$newwidth $ThumbWidth*$imgratio;
//function for resize image.
if (function_exists(imagecreatetruecolor)){
$resized_img imagecreatetruecolor($newwidth,$newheight);
"Error: Please make sure you have GD library ver 2+");
//save image
ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext");
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
move_uploaded_file ($file_tmp"$path_big/$rand_name.$file_ext");

//foto's toevoegen
$sql2 "INSERT INTO images (link,thumb,name) VALUES ('$path_big/$rand_name.$file_ext','$path_thumbs/$rand_name.$file_ext','$name')";
//algemene data invoegen
$sql "INSERT INTO projecten (name,description,video) VALUES ('$name','$description','$video')";
        if( (
$result mysql_query($sql)) && ($result2 mysql_query($sql2)) ) { 
'<p><img src="images/icons/accept.gif" alt"" /> Portfolio item succesvol aangemaakt!</p>'
$page "index.php?page=portfolio";
$sec "1";
header("Refresh: $sec; url=$page");
        } else { 
"ERROR: ".mysql_error(); 
} else { 
HTML Code:
<div id="container">

<form action="" enctype="multipart/form-data" method="post" class="niceform" name="UD">

	<dt><label for="name">Titel:</label></dt>
    <dd><input type="text" name="name" id="name" size="32" maxlength="128" /></dd>
	<dt><label for="description">Beschrijving:</label></dt>
	<dd><textarea name="description" id="description" rows="8" cols="65"></textarea></dd>
<div id="naw0">
		<dt><label for="imgfile">Kies foto:</label></dt>
		<dd><input name="imgfile[]" id="imgfile" type="file" /></dd>
	<dt><label for="video">(Embed) Video:</label></dt>
	<dd><textarea name="video" id="video" rows="8" cols="65"></textarea></dd>
		<dd><input type="submit" name="submit" id="submit" value="voeg toe" onClick="return validateForm()" /></dd>
		<dd><button type="button" onclick="clone();">Nog een afbeelding</button></dd>