Preview image pics before upload javascript - Javascript scripts

preview image pics before upload javascript

 
  • HOME  • tutorials  • photos   • free grafics design   
   



CATEGORIES
EXCEL TUTORIAL
SQL TUTORIAL
WEB INFORMATION
WINDOWS
JAVASCRIPT SCRIPTS
COMPUTER SECURITY
GRAFIC DESIGN
HTML
PHP
CSS STYLE
ATLAS OF THE WORLD
DEVELOPER
PHOTOSHOP
MAGAZINE
LATEST ARTICLES
how to insert decimal values into a sql table row
asrep.com adsense traking script is down
list of walt disney animated movies
free php and ajax captcha scripts
convert uppercase to lowercase javascript online script
detect and block uppercase (up letters) in a string (form text input) php script
php googlebot detection script
replace breaking lines in text or textarea input using php
rounded borders corners css without images
photoshop styles, asl photoshop style free download
  home   JAVASCRIPT SCRIPTS » PREVIEW IMAGE PICS BEFORE UPLOAD JAVASCRIPT
google ads
 
 
 


PREVIEW IMAGE PICS BEFORE UPLOAD JAVASCRIPT


Preview image pics before upload javascript



  It can be very useful to preview an image before uploading, because you can to see wich one you chose it.
Here are two javascript script. Working just in IE because the Firefox has a security action that stop local files previews.

code script:

<script type="text/javascript">
function showImage(str)
{
    document.body.innerHTML+='<br>Uploaded image path: <samp>'+str+'</samp><br><img src="'+str+'" height="100" width="150" alt="">';
}
</script>
<input type="file" id="MainImage" onChange="showImage(this.value)">



Here is the first example : ( look at the bottom of the page )






code script:

<script type="text/javascript">

var maxWidth=100;
  // height to resize large images to
var maxHeight=100;
  // valid file types
var fileTypes=["bmp","gif","png","jpg","jpeg"];
  // the id of the preview image tag
var outImage="previewField";
  // what to display when the image is not valid
var defaultPic="spacer.gif";

/***** DO NOT EDIT BELOW *****/

function preview(what){
  var source=what.value;
  var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
  for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
  globalPic=new Image();
  if (i<fileTypes.length) globalPic.src=source;
  else {
    globalPic.src=defaultPic;
    alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
  }
  setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
  var field=document.getElementById(outImage);
  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";
  field.src=globalPic.src;
  field.width=x;
  field.height=y;
}
// End -->
</script>

 

 

 

<center> Pre-veiw pic from your drive </center>
<div align="center" style="line-height: 1.9em;">

<br>
<input name="userfile" type="file" id="picField" onchange="preview(this)" >


      <br><img id="previewField" alt="" name="previewField" width="1" border="2" height="1" >

 


And here is the second example:

Preveiw image from your drive



 


ARTICLES IN PREVIEW IMAGE PICS BEFORE UPLOAD JAVASCRIPT CATHEGORY

Zero result!!



Tags : Preview image pics before upload,show image before upload,see image before upload,






Leave a comment
Your name *
E-mail * ( it not be posted)
Comment title *
Your comment *
   Anti Spam (fill the number CASE SENSITIVE - UP LETTERS ) *

Subject comments

added by:DIOGO date:03-02-10

Comment title: Muito bom


Legal o script mais uma pergunta por que não funciona no php.???



 

 

the latest articles :
• How to insert decimal values into a SQL table row
• Asrep.com adsense traking script is down
• List of Walt Disney animated movies
• Free PHP and AJAX CAPTCHA scripts
• Convert uppercase to lowercase javascript online script
• Detect and block uppercase (up letters) in a string (form text input) php script
• Php Googlebot detection script
• Replace breaking lines in text or textarea input using php
• Rounded borders corners css without images
• Photoshop styles, asl photoshop style free download

 

eXTReMe Tracker