|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: |
<%@ Page Trace="False" Language="vb" aspcompat="false" debug="true" validateRequest="false"%>
<%@ Import Namespace=System.Drawing %>
<%@ Import Namespace=System.Drawing.Imaging %>
<%@ Import Namespace=System %>
<%@ Import Namespace=System.Web %>
<%@ Import Namespace="System.IO" %>
<SCRIPT LANGUAGE="VBScript" runat="server">
Const Tx = 160 ' max width for thumbnails
Const Ty = 120 ' max height for thumbnails
Const Fx = 360' max width for full images
Const Fy = 240' max height for full images
Const upload_dir = "/img/agents/" ' directory to upload file
Const upload_original = "big" ' filename to save original as (suffix added by script)
Const upload_thumb = "small" ' filename to save thumbnail as (suffix added by script)
Const upload_max_size = 5000 ' max size of the upload (KB) note: this doesn't override any server upload limits
Dim fileExt ' used to store the file extension (saves finding it mulitple times)
Dim newWidth, newHeight As Integer ' new width/height for the thumbnail
Dim l2 ' temp variable used when calculating new size
Dim fileFld As HttpPostedFile ' used to grab the file upload from the form
Dim originalimg As System.Drawing.Image ' used to hold the original image
Dim msg ' display results
Dim upload_ok As Boolean ' did the upload work ?
Dim MyFileName As String
Dim CryptID As String
</script>
<%
Randomize() ' used to help the cache-busting on the preview images
upload_ok = False
If LCase(Request.ServerVariables("REQUEST_METHOD")) = "post" Then
fileFld = Request.Files(0) ' get the first file uploaded from the form (note:- you can use this to itterate through more than one image)
If fileFld.ContentLength > upload_max_size * 1024 Then
msg = "Sorry, the image must be less than " & upload_max_size & "Kb"
Else
Try
originalimg = System.Drawing.Image.FromStream(fileFld.InputStream)
' work out the width/height for the thumbnail. Preserve aspect ratio and honour max width/height
' Note: if the original is smaller than the thumbnail size it will be scaled up
If (originalimg.Width / Fx) > (originalimg.Width / Fy) Then
l2 = originalimg.Width
newWidth = Fx
newHeight = originalimg.Height * (Fx / l2)
If newHeight > Fy Then
newWidth = newWidth * (Fy / newHeight)
newHeight = Fy
End If
Else
l2 = originalimg.Height
newHeight = Fy
newWidth = originalimg.Width * (Fy / l2)
If newWidth > Fx Then
newHeight = newHeight * (Fx / newWidth)
newWidth = Fx
End If
End If
Dim thumb As New Bitmap(newWidth, newHeight)
'Create a graphics object
Dim gr_dest As Graphics = Graphics.FromImage(thumb)
' just in case it's a transparent GIF force the bg to white
Dim sb = New SolidBrush(System.Drawing.Color.White)
gr_dest.FillRectangle(sb, 0, 0, thumb.Width, thumb.Height)
'Re-draw the image to the specified height and width
gr_dest.DrawImage(originalimg, 0, 0, thumb.Width, thumb.Height)
Try
MyFileName = "agent" & request.querystring("pic_id")
fileExt = System.IO.Path.GetExtension(fileFld.FileName).ToLower()
' originalimg.Save(Server.MapPath(upload_dir & MyFileName & "-" & upload_original & fileExt), originalimg.RawFormat)
thumb.Save(Server.MapPath(upload_dir & "/large/" & MyFileName & fileExt), originalimg.RawFormat)
Dim bAns As Boolean
Dim sNewFile As String
Dim BMPFullPath as String
BMPFullPath=Server.MapPath(upload_dir & "/large/" & MyFileName & fileExt)
Try
'bitmap class in system.drawing.imaging
Dim objBmp As New Bitmap(BMPFullPath)
'below 2 functions in system.io.path
sNewFile =Server.MapPath(upload_dir) & "/large/" & MyFileName & ".jpg"
objBmp.Save(sNewFile, ImageFormat.Jpeg)
bAns = True 'return true on success
Catch
bAns = False 'return false on error
End Try
msg = "Uploaded " & fileFld.FileName & " to " & Server.MapPath(upload_dir & upload_original & fileExt)
upload_ok = True
'Using the FileInfo class
Catch ex As Exception
msg = "Sorry, there was a problem saving the image."
End Try
' Housekeeping for the generated thumbnail
If Not thumb Is Nothing Then
thumb.Dispose()
thumb = Nothing
End If
Catch
msg = "Sorry, that was not an image we could process."
End Try
'*******************
'large image
'*******************
Try
originalimg = System.Drawing.Image.FromStream(fileFld.InputStream)
' work out the width/height for the thumbnail. Preserve aspect ratio and honour max width/height
' Note: if the original is smaller than the thumbnail size it will be scaled up
If (originalimg.Width / Tx) > (originalimg.Width / Ty) Then
l2 = originalimg.Width
newWidth = Tx
newHeight = originalimg.Height * (Tx / l2)
If newHeight > Ty Then
newWidth = newWidth * (Ty / newHeight)
newHeight = Ty
End If
Else
l2 = originalimg.Height
newHeight = Ty
newWidth = originalimg.Width * (Ty / l2)
If newWidth > Tx Then
newHeight = newHeight * (Tx / newWidth)
newWidth = Tx
End If
End If
Dim full As New Bitmap(newWidth, newHeight)
'Create a graphics object
Dim gr_dest As Graphics = Graphics.FromImage(full)
' just in case it's a transparent GIF force the bg to white
Dim sb = New SolidBrush(System.Drawing.Color.White)
gr_dest.FillRectangle(sb, 0, 0, full.Width, full.Height)
'Re-draw the image to the specified height and width
gr_dest.DrawImage(originalimg, 0, 0, full.Width, full.Height)
Try
fileExt = System.IO.Path.GetExtension(fileFld.FileName).ToLower()
' originalimg.Save(Server.MapPath(upload_dir & MyFileName & "-" & upload_original & fileExt), originalimg.RawFormat)
full.Save(Server.MapPath(upload_dir & "/small/" & MyFileName & fileExt), originalimg.RawFormat)
Dim bAns As Boolean
Dim sNewFile As String
Dim BMPFullPath as String
BMPFullPath=Server.MapPath(upload_dir & "/small/" & MyFileName & fileExt)
Try
'bitmap class in system.drawing.imaging
Dim objBmp As New Bitmap(BMPFullPath)
'below 2 functions in system.io.path
sNewFile =Server.MapPath(upload_dir) & "/small/" & MyFileName & ".jpg"
objBmp.Save(sNewFile, ImageFormat.Jpeg)
objBmp.Dispose()
bAns = True 'return true on success
Catch
bAns = False 'return false on error
End Try
msg = "Uploaded " & fileFld.FileName & " to " & Server.MapPath(upload_dir & upload_original & fileExt)
upload_ok = True
'Using the FileInfo class
Catch ex As Exception
msg = "Sorry, there was a problem saving the image."
End Try
' Housekeeping for the generated thumbnail
If Not full Is Nothing Then
full.Dispose()
full = Nothing
End If
Catch
msg = "Sorry, that was not an image we could process."
End Try
End If
' House Keeping !
If Not originalimg Is Nothing Then
originalimg.Dispose()
originalimg = Nothing
End If
End If
%>
<html>
<head>
<LINK href="/rhino.css" type=text/css rel=stylesheet>
</head>
<body>
<center>
<table width=550 bgcolor=white><tr><td align=center><br>
<br>
<p>
</p>
<form id="Form1" enctype="multipart/form-data" method="post" runat="server">
<table>
<tr><td>Select the new file to upload:</td></tr><tr><td><input type="file" name="upload_file"></td></tr>
<tr><td colspan=1><input type="submit" value="Upload" id="Submit1" language="javascript" onclick="return Submit1_onclick()">
</table>
</form>
<%
If upload_ok Then
%>
<script language="JavaScript" type="text/javascript">
opener.agentpic.src="<%=upload_dir & "/large/" & MyFilename & ".jpg?" & rnd()%>";
window.close();
</script>
<table>
<tr>
<td valign=top align=center>
<img src="<%=upload_dir & "/large/" & MyFilename & ".jpg?" & rnd()%>"></td>
</tr>
</table>
<%
Else
Response.Write(msg)
End If
%><br>
</td></tr></table>
</center>
</body>
</html>
|
Advertisement
| Hall of Fame |