How to create a current year to 1900 select box in JSP

hey guys,

i got one simple logic to create a current year to 1900 select box. lets go for coding.


Date dNow = new Date( );    
SimpleDateFormat = new SimpleDateFormat ("yyyy");    
String year = ft.format(dNow);    
int foo = Integer.parseInt(year);    
while(foo > 1989)

<option value=”<%=foo%>”><%=foo%></option>




Image upload validation using php

hello guys,

sometime it is necessary to check whether the uploaded file is valid Image file or not ?  or sometime you need to allow user to upload only few image extension file.  let’s say you want to allow user to upload only (gif, jpeg, jpg, png) extension file.

so let’s go for coding.

HTML Coding

<form method="post" action="uploadimage.php" enctype="multipart/form-data">
<td> Upload Image here : </td>
<td> <input type="file" name="file"> </td>
<td> <input type="submit" value="upload"> </td>

PHP Coding (uploadimage.php)

$allowedExts = array("jpg", "jpeg", "gif", "png");
$arr = explode(".", $_FILES["file"]["name"]);
$extension = end($arr);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg"))
&& in_array($extension, $allowedExts))
   if ($_FILES["file"]["error"] > 0)
        echo "Error: " . $_FILES["file"]["error"] . "<br />";
      move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"] );
      echo "<script>alert('file uploaded successfully')</script>";
      echo "Invalid file";

Please make sure that you have upload folder in your current directory.!

Hope you enjoy this small script!

Creating HTML elements dynamically using jquery

sometime during your project you need to create some html elements dynamically based on user’s choice.

for example you are providing upload facilities to user such that initially only one upload widget is available but if user want to upload more things, they will click on add button and based on that upload widgets should created and appear there.

so you need to use two methods of jquery.

  • live method
  • clone method

1) live method:

The live() method attaches one or more event handlers for selected elements, and specifies a function to run when the events occur.

Event handlers attached using the live() method will work for both current and FUTURE elements matching the selector (like a new element created by a script).

2) clone method:

The clone() method makes a copy of selected elements, including child nodes, text and attributes.

now let’s write code for creating dynamic elements.


<!DOCTYPE html>
<script src=”jquery.js”></script>

<div class=’Option’><input type=’text’ name=’t1′/>
<span class=’Add’><img src=”add.png” height=”30″ width=”30″/></span>


if you press add button you will get another same row of textbox and add button.!

hope you like it.!