Location: PHPKode > scripts > Create Your Own Directory > cms/admin/upload.php
<?php
include "authheader.php";
if($block != true)
{
?>
<!-- Welcome to the scripts database of HIOX INDIA      -->
<!-- This tool is developed and a copyright             -->
<!-- product of HIOX INDIA.				        -->
<!-- For more information visit http://www.hscripts.com -->
<html>
<head>
</head>
<body style="margin: 0px;">
<?php include "heade.php" ?>

<table width=790 height=100% border=0  cellpadding=0 cellspacing=0 align=center><tr><td align=center>
<tr height=100%><td class=maintext valign=top>
<html>
<br><br>
<table align=center border=0 height=90% bgcolor=#f8f8ff  width=80%><tr><td>
<script language="javascript">


var browser = navigator.appName;
function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var httpa;
function testAjax(idd,home,opr)
{

	httpa = createRequestObject(); 
	var str="imagedisplay.php?idd="+idd+"&home="+home+"&opr="+opr;
	httpa.open('get', str);
	httpa.onreadystatechange = handleResponse;
	/* Send the data. We use something other than null when we are sending using the POST
	method. */
	httpa.send(null);
}

function handleResponse() {
	if(httpa.readyState == 4){
	var response = httpa.responseText;
	var res=response.split("---");
	if(res[0]=="display"){
		var xx=document.getElementById("imgg");
		xx.innerHTML=res[1];
	}else if(res[0]=="default")
	{
		var xx=document.getElementById("res");
		xx.innerHTML=res[1];

	}
	}
}

</script>


<?php
$wth=$_POST['width'];
$ht=$_POST['height'];
$linkk=$_POST['link'];
$name=$_POST['nam'];
$id=$_POST['idd'];
//echo "---$id";
$i=0;
$qry="select * from images";
$result=mysql_query($qry);
$field=array();
$image=array();
$width=array();
$height=array();
$imgid=array();
$link=array();
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{	
	$field[$i] = $line['field'];
	$image[$i] = $line['image'];
	$width[$i] = $line['width'];
	$height[$i] = $line['height'];
	$uwidth[$i] = $line['uwidth'];
	$uheight[$i] = $line['uheight'];
      $link[$i] = $line['link'];
	$img=$line['imgid'];
	$imgid[$i]=$img;
	$i++;
}

?>
<?php
$sub=$_POST['sub'];
if($sub=="yes")
{
 $home= $HTTP_POST_FILES['image']['tmp_name'];
$fp = fopen($home,"rb");
while(!feof($fp))
{
$data .= fread($fp,1024);
}
fclose($fp);
$data = addslashes($data);
if($linkk!="" && img!="" && $wth!="" && $ht!=""){
$qry="update images set img='$data',typ='updated', uwidth=$wth, uheight=$ht, link='$linkk'  where imgid=$id";
}else if($linkk=="" && img!="" && $wth=="" && $ht==""){
$qry="update images set img='$data',typ='updated' where imgid=$id";
}else if($linkk!="" && img!=""  && $wth=="" && $ht==""){
$qry="update images set img='$data',typ='updated', link='$linkk'  where imgid=$id";
}else if($linkk=="" && img!=""  && $wth!="" && $ht!=""){
$qry="update images set img='$data',typ='updated',  uwidth=$wth, uheight=$ht where imgid=$id";
}

$res=mysql_query($qry);
if($res)
echo"<div align=center style='color:green; font-size:14px;'>Your selected image is uploaded successfully<br></div>";
}

?>
<table border=0 height=100% border=1>
<form method="POST" enctype="multipart/form-data"  action="">
<tr><td colspan=3><div id=res></div></td></tr>

<tr><td colspan=3>
<b>Edit Imageset</b></td></tr>
<tr><td  width=200>Select Image</td><td>
<?php
echo"<select name=imgname id=sel>";
for($k=0;$k<count($field);$k++)
{
echo"<option name=nam  value=$imgid[$k]> $field[$k]</option>";
}
echo"</select>";
?>

<input type=button value=select onclick="disp();"></td></tr>
<tr><td> Current Image</td><td colspan=2><div id=imgg><img id=cruimg src=<?php echo($home."/image/".$image[0]); ?> ></div></td></tr>
<!--tr><td> Selected Image</td><td colspan=2><image src=<?php echo($home."/image/".$fields[0]); ?> ></td></tr-->
<tr><td colspan=3><br><b>Change New Image Instead of Default Image</b></td></tr>
<tr><td >Image</td><td align=left colspan=2> <input type="file" name="image"><input name="Submit" type="submit" value="Upload"><input type=hidden name=sub value='yes'>
<input id=imgnm type=hidden name=idd >
<input id=old type=hidden name=nam >
</td></tr>
<tr><td >Image Width</td><td colspan=2><input type=text name=width></input></td></tr> 
<tr><td >Image Height</td><td colspan=2><input type=text name=height></input><br></td></tr> 
<tr><td >Link</td><td colspan=2><input type=text name=link ></input><br></td></tr> 
<tr><td colspan=3><br><b>Replace Default Image</b></td></tr>
<tr><td >Select Default Image</td><td align=left colspan=2> <input type="checkbox" value="DefaultImg" id="chkbox">Set Images to default image &nbsp;&nbsp;<input type=button value="SetDefault" onclick=defaultimg()><br><br><br></td></tr>

</form>
</table> 
<script language="javascript">
function disp()
{
	var sell=document.getElementById("sel");
	var idd=sell.value;
	//var elm=document.getElementById("cruimg");
	var olld=document.getElementById("old");
   	//elm.src=home+"image/img"+idd+".gif";
	olld.value="img"+idd;
var imgget=document.getElementById("imgnm");
imgget.value=idd;
//alert(imgget.value);
var opr="insertimg";
testAjax(idd,home,opr);
}
function defaultimg()
{
	var sell=document.getElementById("sel");
	var idd=sell.value;
	//var elm=document.getElementById("cruimg");
	var olld=document.getElementById("old");
   	//elm.src=home+"image/img"+idd+".gif";
	olld.value="img"+idd;
var imgget=document.getElementById("imgnm");
var cbox=document.getElementById("chkbox");
imgget.value=idd;

if(cbox.checked == true)
{
//alert(imgget.value);
var opr="setdefault";
testAjax(idd,home,opr);
}
}

</script>
  </td></tr>
<!-- content row -->
<tr><td width=100% align=right>
a product by &copy; <a href="http://www.hscripts.com" 
style="font-size: 14px; color: 347777; text-decoration:none;">hscripts.com</a> 
&nbsp; &nbsp; &nbsp; &nbsp;<br>
</td></tr>
</table>
<!-- main table -->
<br><br></td></tr>
</table>
<tr><td height=20 bgcolor=white>
</td></tr></table>

</body>
</html>
<?php
}
?>
<!-- Welcome to the scripts database of HIOX INDIA      -->
<!-- This tool is developed and a copyright             -->
<!-- product of HIOX INDIA.				        -->
<!-- For more information visit http://www.hscripts.com -->



Return current item: Create Your Own Directory