Went in. Just Y height and width went in
Should $basename etc be ´basename´?

I shall try it

Still no luck mate. Adds some info but not other......doesn't add image properties...size extension etc.
It also addds each uploaded image to a new testimonial id....how can i add multiple images to the one testimonial please?

Thanks,
Steve

Did you do another var_dump(); on your query and copy and paste the output manually into the mysql terminal?

Yes, the manual query was the one i did

<?php

if($_POST['pgaction']=="upload")
    upload();
else
    uploadForm();

//The form having dynamic file uploader
function uploadForm() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> :: FILEUPLOAD :: </title>
<link href="style.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function _add_more() {
        var txt = "<br><input type=\"file\" name=\"item_file[]\">";
        document.getElementById("dvFile").innerHTML += txt;
    }
    function validate(f){
        var chkFlg = false;
        for(var i=0; i < f.length; i++) {
            if(f.elements[i].type=="file" && f.elements[i].value != "") {
                chkFlg = true;
            }
        }
        if(!chkFlg) {
            alert('Please browse/choose at least one file');
            return false;
        }
        f.pgaction.value='upload';
        return true;
    }
//-->
</script>
</head>

<body bgcolor="#C8C8C8" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">


<!--session_start();


$con=mysql_connect("localhost", "root", "") or die(mysql_error()) ; 
 mysql_select_db("reg_db",$con) or die("cannot select DB") ; 
-->
<?php if ($GLOBALS['msg']) { echo '<center><span class="err">'.$GLOBALS['msg'].'</span></center>'; }?><br>


<form name="frm" method="post" onsubmit="return validate(this);" enctype="multipart/form-data">
<input type="hidden" name="pgaction">

    <table align="center" cellpadding="4" cellspacing="0" bgcolor="#EDEDED"> 
        <tr class="tblSubHead">
            <td colspan="2">Upload any number of file</td>
        </tr>
        <tr class="txt">
            <td valign="top"><div id="dvFile"><input type="file" name="item_file[]"></div></td>
            <td valign="top"><a href="javascript:_add_more();" title="Add more"><img src="plus_icon.gif" border="0"></a></td>
        </tr>
        <tr>
            <td align="center" colspan="2"><input type="submit" value="Upload File"></td>
        </tr>
    </table>
</form>

</body>
</html>
<?php
}
session_start();


$con=mysql_connect("localhost", "root", "") or die(mysql_error()) ; 
 mysql_select_db("reg_db",$con) or die("cannot select DB") ; 


 function upload(){

                if(count($_FILES["item_file"]['name'])>0)
                 { //check if any file uploaded
                    $GLOBALS['msg'] = ""; //initiate the global message
                    for($j=0; $j < count($_FILES["item_file"]['name']); $j++)
                     { //loop the uploaded file array
                    $filen=$_FILES["item_file"]["name"]["$j"] ;
                    $tname=$_FILES["item_file"]["tmp_name"]["$j"];
                    $size=$_FILES["item_file"]["size"]["$j"];
                    $oext=getExtention($filen);
                    $ext=strtolower($oext);
                    $base_name=getBaseName($filen);
                    $path = "uploads/".$filen; //generate the destination path

                     if($ext=="jpg" || $ext=="jpeg" || $ext=="bmp" || $ext=="gif" || $ext=="txt" || $ext=="pdf" || $ext=="docx" || $ext=="doc")
                     {
            if($size< 5024*5024){

                if(file_exists($path)){


                    move_uploaded_file($tname,$path ); //upload the file
                    $result = 1;                    
                    list($width,$height)=getimagesize($path);
                    $qry="select id from image where img_base_name='$base_name' and img_ext='$ext'";
                    $res=mysql_fetch_array(mysql_query($qry));
                    $id=$res['id'];

                    $qry="UPDATE image SET img_base_name='$base_name', img_ext='$ext', img_height='$height', img_width='$width', size='$size', img_status='Y' where id=$id";
                    mysql_query($qry);
                    $GLOBALS['msg'] .= "File# ".($j+1)." ($filen) updated successfully<br>";
                    }
                    else
                    {
                    move_uploaded_file($tname,$path );
                    $result = 1;
                    list($width,$height)=getimagesize($path);
                    $qry="INSERT INTO image(id, img_base_name, img_ext, img_height, img_width, size, img_status)VALUES (NULL , '$base_name', '$ext', '$height', '$width', '$size', 'Y')";
                    mysql_query($qry);
                    print_r($qry);
                    $GLOBALS['msg'] .= "File# ".($j+1)." ($filen) uploaded successfully<br>";
                    }
                }
                }
                else{
                    $GLOBALS['msg'] = "Invalid file extention '.$oext'";
                    }
            }
}
else {
        $GLOBALS['msg'] = "No files found to upload"; //Failed message  
    }
    uploadForm(); //display the main form
  }
function getExtention($image_name)
{
return substr($image_name,strrpos($image_name,'.')+1);
}
function getBaseName($image_name)
{
return substr($image_name,0,strrpos($image_name,'.'));


}

?>

The above code posted by me,it has some problem with upload file in the database. but it upload the file into the folder fine. so can any one plz help me. i just modify the above code posted in this topic.

Just a late note for those who may use this thread. I tried the very first code, I guess it has been updated after the messages, it worked out of the box (add config file and new directory).
Then I copied the same file into the final folder... and didn't work (file was uploaded, but DB was not updated). No changes whatsover in the code. After a few hours.... the problem was the connection. I don't know PHP, but I think the conn stays opened. As soon as changed my config file, everything worked as a charm.

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.