Click here to Skip to main content
15,922,650 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: preview a picture from my hard disk before upload it Pin
ayeleteric30-Jul-07 0:06
ayeleteric30-Jul-07 0:06 
GeneralRe: preview a picture from my hard disk before upload it Pin
enjoycrack30-Jul-07 0:09
enjoycrack30-Jul-07 0:09 
GeneralRe: preview a picture from my hard disk before upload it Pin
ayeleteric30-Jul-07 0:18
ayeleteric30-Jul-07 0:18 
GeneralRe: preview a picture from my hard disk before upload it Pin
enjoycrack30-Jul-07 0:21
enjoycrack30-Jul-07 0:21 
GeneralRe: preview a picture from my hard disk before upload it Pin
enjoycrack30-Jul-07 0:24
enjoycrack30-Jul-07 0:24 
GeneralRe: preview a picture from my hard disk before upload it Pin
ayeleteric30-Jul-07 1:02
ayeleteric30-Jul-07 1:02 
GeneralRe: preview a picture from my hard disk before upload it Pin
Guffa30-Jul-07 1:13
Guffa30-Jul-07 1:13 
GeneralRe: preview a picture from my hard disk before upload it Pin
ayeleteric30-Jul-07 1:16
ayeleteric30-Jul-07 1:16 
Thank you Guffa,

Here is my code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>

<script type="text/javascript">
// width to resize large images to
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="box_icons.jpg";

/***** 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>
</head>

<body>
<div style="line-height: 1.9em; text-align:center">
Test it by locating a valid file on your hard drive:
<br/>
<input type="file" id="picField" onchange="preview(this)"/>
<br/>
<img alt="Graphic will preview here" id="previewField" style="width: 288px; height: 272px;"/>&nbsp;<br/>
</div>
</body>

</html>


Eric H.
GeneralRe: preview a picture from my hard disk before upload it Pin
ayeleteric30-Jul-07 2:59
ayeleteric30-Jul-07 2:59 
QuestionAutocompleteText of TextBox Pin
Imran Khan Pathan29-Jul-07 22:46
Imran Khan Pathan29-Jul-07 22:46 
AnswerRe: AutocompleteText of TextBox Pin
enjoycrack29-Jul-07 23:58
enjoycrack29-Jul-07 23:58 
Questionhow to assign QueryString value to a variable Pin
hurrem29-Jul-07 22:39
hurrem29-Jul-07 22:39 
AnswerRe: how to assign QueryString value to a variable Pin
Imran Khan Pathan29-Jul-07 22:57
Imran Khan Pathan29-Jul-07 22:57 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem29-Jul-07 23:09
hurrem29-Jul-07 23:09 
GeneralRe: how to assign QueryString value to a variable Pin
Imran Khan Pathan30-Jul-07 3:15
Imran Khan Pathan30-Jul-07 3:15 
AnswerRe: how to assign QueryString value to a variable Pin
enjoycrack29-Jul-07 23:59
enjoycrack29-Jul-07 23:59 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem30-Jul-07 0:20
hurrem30-Jul-07 0:20 
GeneralRe: how to assign QueryString value to a variable Pin
enjoycrack30-Jul-07 0:23
enjoycrack30-Jul-07 0:23 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem30-Jul-07 0:25
hurrem30-Jul-07 0:25 
AnswerRe: how to assign QueryString value to a variable Pin
Piyush Vardhan Singh30-Jul-07 0:46
Piyush Vardhan Singh30-Jul-07 0:46 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem30-Jul-07 0:50
hurrem30-Jul-07 0:50 
GeneralRe: how to assign QueryString value to a variable Pin
Piyush Vardhan Singh30-Jul-07 1:10
Piyush Vardhan Singh30-Jul-07 1:10 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem30-Jul-07 1:14
hurrem30-Jul-07 1:14 
GeneralRe: how to assign QueryString value to a variable Pin
hurrem30-Jul-07 1:18
hurrem30-Jul-07 1:18 
GeneralRe: how to assign QueryString value to a variable Pin
N a v a n e e t h30-Jul-07 2:54
N a v a n e e t h30-Jul-07 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.