SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-17-2006, 11:56 PM
real_estate real_estate is offline
SEO Junior and a half
 
Join Date: Jul 2006
Posts: 83 real_estate is on a distinguished road
File upload

How do you browse a partictular file(.txt, .doc, image, etc) and display it
on the webpage using ASP.Net.
__________________
SBalan Group
http://www.sbalanprojects.com/
Reply With Quote
  #2  
Old 07-20-2006, 10:17 AM
abhishekmat's Avatar
abhishekmat abhishekmat is offline
SEO
 
Join Date: Nov 2004
Location: Bangalore, India
Posts: 381 abhishekmat will become famous soon enough
__________________
Package tour offers kerala tourism

Check Free Directory List
Reply With Quote
  #3  
Old 08-18-2006, 11:29 AM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Hi

Below is example code for file uploading in ASP.Net 2.0

Code:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
    Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs)
        If (upImage.HasFile) Then
            If (CheckFileType(upImage.FileName)) Then
                Dim filePath As String = "~/UploadImages/" & upImage.FileName
                upImage.SaveAs(MapPath(filePath))
            End If
        End If
    End Sub
 
    Function CheckFileType(ByVal fileName As String) As Boolean
        Dim ext As String = Path.GetExtension(fileName)
        Select Case ext.ToLower()
            Case ".gif"
                Return True
            Case ".png"
                Return True
            Case ".jpg"
                Return True
            Case ".jpeg"
                Return True
            Case Else
                Return False
        End Select
    End Function
 
    Sub Page_PreRender()
        Dim upFolder As String = MapPath("~/UploadImages/")
        Dim dir As New DirectoryInfo(upFolder)
        dlstImages.DataSource = dir.GetFiles()
        dlstImages.DataBind()
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>FileUpload File</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:Label
        id="lblImageFile"
        Text="Image File:"
        AssociatedControlID="upImage"
        Runat="server" />

    <asp:FileUpload
        id="upImage"
        Runat="server" />

    <br /><br />
    
    <asp:Button
        id="btnAdd"
        Text="Add Image"
        OnClick="btnAdd_Click" 
        Runat="server" />

    <hr />
    
    <asp:DataList
        id="dlstImages"
        RepeatColumns="3"
        runat="server">
        <ItemTemplate>
        <asp:Image ID="Image1" 
            ImageUrl='<%# Eval("Name", "~/UploadImages/{0}") %>'
            style="width:200px"
            Runat="server" />
        <br />
        <%# Eval("Name") %>    
        </ItemTemplate>
    </asp:DataList>
    
    </div>
    </form>
</body>
</html>

Hope this helps a bit? Its a very simple example, but should hopefully set you on the right track.

Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 03:05 AM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.