<html><head>
<script language="javascript">
function image_rep(x)
{
document.getElementById('imageshow').innerHTML="<img src='images/"+x+"'>";
}
</script>
</head><body>
<div style="clip: rect('top', 'right', 'bottom', 'left'); height:300px; width:300px; overflow:scroll; float:left; text-transform:lowercase;">
<?php
//Open images directory with chmod 0777
$dir = opendir("images");
$dir_image_no=0;
//List files in images directory
while (($file = readdir($dir)) !== false)
{
if ($file != "." && $file != "..")
{
echo "<a href='#' onClick='image_rep(\"".$file."\");'>". $file . "</a><br/>";
$dir_image_no++;
}
}
closedir($dir);
?>
</div>
<div align='left' id="imageshow" style="float:inherit"></div>
<div style="clear:both;"></div>
<div id="photo_lib_upload" >
<?
//code for image upload
if(isset($_POST['subFrm'])&&($_POST['subFrm']="1"))
{
$filename=$_FILES["photo"]["name"];
$ext=explode(".",$filename);
$arrlen=sizeof($ext); //length of array contaning file name
if((strtolower($ext[$arrlen-1])!="php")||(strtolower($ext[$arrlen-1])!="js"))
{
if((strtolower($ext[$arrlen-1])=="jpeg")||(strtolower($ext[$arrlen-1])=="jpg")||(strtolower($ext[$arrlen-1])=="png")||(strtolower($ext[$arrlen-1])=="gif"))
{
$finalname=time().str_replace(" ","_",$_FILES["photo"]["name"]); //echo"filename".$finalname;
move_uploaded_file($_FILES["photo"]["tmp_name"],"images/".$finalname);
$frm_inv="Your image has been uploaded successfully. <a href=# onclick='window.open(\"images/".$finalname."\",\"\",\"height=200,width=600,address=no\");return false;'> Click here </a>to View your uploaded image.";
$frm_col="black";
}
else
{
$frm_inv="Invalid file format :".$_FILES["photo"]["name"];
$frm_col="red";
}
}
else
{
$frm_inv="Invalid file format :".$_FILES["photo"]["name"];
$frm_col="red";
}
}
?>
<form action="" method="post" enctype="multipart/form-data" name="upload_frm">
<table>
<tr><td ALIGN="RIGHT">
<font face="Verdana" color="#75B04F"><strong>Image upload:</strong></FONT><br/><font face="Verdana" size="-2">(jpg, gif, png format only)</font>
</td>
<td class="td1" align="right"><input type="file" name="photo" onChange="img_uplo();"><input type="hidden" value="<?php echo $finalname; ?>" id="file"><input type="hidden" value="<?php echo $finalname; ?>" id="file1"><input type="hidden" name="subFrm" id="subFrm" value="1" />
</td>
</tr>
</table>
</form>
</body>
<script language="javascript">
function img_uplo()
{
document.upload_frm.submit();
}
</script>
</div>
<body>
</html>
Secure file download in PHP, Security question PHP, PHP MYSQL Interview Question -Books download - PHP solutions guidelines queries update, phpmysqlquestion
Showing posts with label Generation of Photo Library. Show all posts
Showing posts with label Generation of Photo Library. Show all posts
Tuesday, December 16, 2008
Subscribe to:
Posts (Atom)
Kubernetes in one shotcat
root@srv509172:~# cat kind1/config.yaml kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane image: kindest/nod...
-
Introduction to PHP PDO (PHP Data Objects) 1. What is PDO 2. What Databases does PDO support 3. Where do I begin? 4. Connect to ...
-
SimpleXML does not parse text inside CDATA tags in an XML. Consider the XML below: $str = ''; $str.='some text goes here'; ...
-
var collectionNames = db.getCollectionNames(), stats = []; collectionNames.forEach(function (n) { stats.push(db[n].stats()); }); stats = s...