Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP.NET > ASP.NET Image > ASP.NET Upload & Resize Image



Clound SSD Virtual Server

ASP.NET Upload & Resize Image

ASP.NET Upload & Resize Image เป็นการสร้าง Form Upload และทำการ Resize รูปภาพที่ได้จากการ อัพโหลด

Language Code : VB.NET || C#

Framework : 2,3,4

AspNetUploadResizeImages.aspx

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>

<script runat="server">

    Sub btnUpload_OnClick(sender As Object, e As EventArgs)
		
		If Me.fiUpload.HasFile Then 
		
			Dim intWidth,intHeight As Integer
			Dim UlFileName,NewFileName As String

			intWidth = 	100 '*** Fix Width ***'
			'intHeight = 0   '*** If = 0 Auto Re-Cal Size ***'
			intHeight = 120	

			UlFileName = "MyImages/" & fiUpload.FileName
			
			'*** Save Images ***'
			Me.fiUpload.SaveAs(Server.MapPath(UlFileName))

			NewFileName = "MyImages/Thumbnail_" & fiUpload.FileName


			Dim objGraphic As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(UlFileName))

			Dim objBitmap As Bitmap
			'*** Calculate Height ***'
			If intHeight > 0 Then
				objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
			Else
				If objGraphic.Width > intWidth Then
					Dim ratio As Double = objGraphic.Height / objGraphic.Width
					intHeight = ratio * intWidth
					objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
				Else
					objBitmap = New Bitmap(objGraphic)
				End If
			End If
			
			'*** Save As  ***'
			objBitmap.Save(Server.MapPath(NewFileName), objGraphic.RawFormat) 
			
			'*** Close ***'
			objGraphic.Dispose()

			'*** View Images ***'
			Me.imgPicture.Visible = True
			Me.imgPicture.ImageURL = NewFileName


		End IF

	End Sub

</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Images (System.Drawing)</title>
</head>
<body>
	<form id="form1" runat="server">
		<asp:FileUpload id="fiUpload" runat="server"></asp:FileUpload>
		<input id="btnUpload" type="button" OnServerClick="btnUpload_OnClick"  value="Upload" runat="server" />
		<hr />
		<asp:Image id="imgPicture" Visible="false" runat="server" /><br /><br />
	</form>
</body>
</html>
</form>


Screenshot

ASP.NET Image

ASP.NET Image






   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2008-10-26 20:19:45 / 2009-06-03 07:56:45
  Download : Download  ASP.NET Upload & Resize Image
 Sponsored Links / Related

 
ASP.NET Create Image
Rating :

 
ASP.NET Write Text to Image
Rating :

 
ASP.NET Write Text to Picture
Rating :

 
ASP.NET (Watermark) Upload and Write Text to Picture
Rating :

 
ASP.NET Add Logo/CopyRight to Image
Rating :

 
ASP.NET Upload and Add Logo/CopyRight to Image
Rating :

 
ASP.NET Resize Image
Rating :

 
ASP.NET Create Thumbnail Image
Rating :

 
ASP.NET Upload Resize Insert to Database
Rating :

 
ASP.NET Multiple Upload & Multiple Resize
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่