Return to Snippet

Revision: 61463
at December 14, 2012 15:31 by laxman2021


Initial Code
<script language="javascript">
function Checkfiles()
{
var fup = document.getElementById('filename');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "doc")
{
return true;
} 
else
{
alert("Upload Gif or Jpg images only");
fup.focus();
return false;
}
}
</script>


<li class="two">
<div class="left_nor"><input type="file" id="logo1" onchange="Checkfiles()" multiple accept='image/*' name="txtLogoFileName" tabindex="20" value="<?php if($_POST["txtLogoFileName"]) echo $_POST["txtLogoFileName"]; else echo($LogofileName); ?>" /></div> </li>

Initial URL
http://stackoverflow.com/questions/8021880/javascript-validate-filename-before-upload

Initial Description
javascript image uplaod

Initial Title
Validating Image field for Uploading  Images in javascript.

Initial Tags
javascript, image

Initial Language
PHP