/ Published in: PHP

javascript image uplaod
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>
URL: http://stackoverflow.com/questions/8021880/javascript-validate-filename-before-upload
Comments
