Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2004, 10:07 AM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ctranjith
Default How Load An Image

Sir
   I am in great problem that I need to load an image from Client and save it in Server (jpeg ) file , Sir can you help me to do that and tell me what are controls that i need to do it and the code also for it in asp.net (using Vb).

Expecting reply


 
Old November 20th, 2004, 03:33 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can look at: http://support.microsoft.com/default...b;en-us;315832
or here it the summary of that:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
        <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server" EncType="multipart/form-data" action="/?scid=WebForm1.aspx&fp=1">
            Image file to upload to the server: <INPUT id="oFile" type="file" runat="server" NAME="oFile">
            <asp:button id="btnUpload" type="submit" text="Upload" runat="server"></asp:button>
            <asp:Panel ID="frmConfirmation" Visible="False" Runat="server">
                <asp:Label id="lblUploadResult" Runat="server"></asp:Label>
            </asp:Panel>
        </form>
    </body>
</HTML>

Imports System.IO
Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents btnUpload As System.Web.UI.WebControls.Button
    Protected WithEvents lblUploadResult As System.Web.UI.WebControls.Label
    Protected WithEvents frmConfirmation As System.Web.UI.WebControls.Panel
    Protected WithEvents oFile As System.Web.UI.HtmlControls.HtmlInputFile

#Region " Web Form Designer Generated Code "

    'The Web Form Designer requires this call.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

Private Sub Page_Init(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: The Web Form Designer requires this method call.
        'Do not use the code editor to modify it.
        InitializeComponent()
    End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
        'Insert user code to initialize the page here.
    End Sub

Private Sub btnUpload_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnUpload.Click
        Dim strFileName As String
        Dim strFilePath As String
        Dim strFolder As String

        strFolder = "C:\Temp\"

        'Get the name of the file that is posted.
        strFileName = oFile.PostedFile.FileName
        strFileName = Path.GetFileName(strFileName)

        'Create the directory if it does not exist.
        If (Not Directory.Exists(strFolder)) Then
            Directory.CreateDirectory(strFolder)
        End If

        'Save the uploaded file to the server.
        strFilePath = strFolder & strFileName
        If File.Exists(strFilePath) Then
lblUploadResult.Text = strFileName & " already exists on the server!"
        Else
            oFile.PostedFile.SaveAs(strFilePath)
lblUploadResult.Text = strFileName & " has been successfully uploaded."
        End If

        'Display the result of the upload.
        frmConfirmation.Visible = True

    End Sub
End Class







Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i load a wmf image jerryham VB.NET 0 October 20th, 2008 12:55 PM
load a image from database pedrocosta24306 BOOK: Access 2003 VBA Programmer's Reference 0 January 5th, 2007 11:35 PM
how to load an image from servlet austinf Servlets 0 June 16th, 2006 02:00 AM
Load Image from file to TPaintBox sencee C++ Programming 0 April 7th, 2005 06:58 AM
Load image from URL JonnyRPI ASP.NET 1.0 and 1.1 Basics 0 June 9th, 2003 06:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.