hello all,
if user uploading image for first time it will insert and if changing image then update query process..
my problem is that i am providing a popup window for image upload.i want after upload image childwindow should close and parent window reload or refrsh...
i tried a lot but nothing going well......
i am calling javascript funtion when insert or update query execute fine...but problem.....
<body>
<center>
<?php
if(isset($_POST['submit']))
{
$n=$_FILES['ufile']['name'];
$t=$_FILES["ufile"]["type"];
$s=$_FILES["ufile"]["size"];
if ((($_FILES["ufile"]["type"] == "image/gif") || ($_FILES["ufile"]["type"] == "image/jpeg")||($_FILES["ufile"]["type"] == "image/pjpeg"))&& ($_FILES["ufile"]["size"] < 102400))
{
if ($_FILES["ufile"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["ufile"]["tmp_name"],"upload/".$_FILES["ufile"]["name"]);
$uii=$_SESSION['id'];
$q_f_a="select * from image where user_image_id=".$uii;
$result=mysql_query($q_f_a);
if((mysql_num_rows($result)>0))
{
$q="update table set image_type='".$t."',image_size='".$s."',image_name='".$n."' where user_image_id='".$uii."'";
$result=mysql_query($q);
$nr=mysql_affected_rows();
if(nr>0)
{
echo "<SCRIPT language=JavaScript type=text/javascript>function win(){window.opener.document.location.reload();
self.close();}</script>";
}
}
else
{
$q="insert into table(image_type,image_size,image_name,user_image_id) values('$t','$s','$n','$uii')";
$result=mysql_query($q);
$nr=mysql_affected_rows();
if(nr>0)
{
echo "<SCRIPT language=JavaScript type=text/javascript>function win(){window.opener.document.location.reload();
self.close();}</script>";
}
}
}
}
else
{
echo "Invalid file-Your File Should";
}
}
?>
<form enctype="multipart/form-data" method="POST" name="frmupload" action="<?php echo $_SERVER['PHP_SELF']?/>
Select an Image: <input name="ufile" type="file" id="ufile"/>
<input type="submit" value="Upload" name="submit" onClick="win();" id="submit" />
</form>
</center>
</body>
</html>