<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)
How to solve mysql ERROR 1118 (42000) Row size too large
I had this issue with MYSQL 5.7 . The following worked althoug...
-
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 ...
-
SQLSTATE[HY000]: General error MySQL: 1364 Field 'coloum' doesn't have a default value, how to solveWith the root access of the mysql, do the following changes select @@ GLOBAL . sql_mode In my case, I get the following: ONLY_FULL_...
-
I had this issue with MYSQL 5.7 . The following worked althoug...