PostedFile.SaveAs going to browse window automatically ???

Discussion in 'ASP .Net' started by jason, Nov 5, 2004.

  1. jason

    jason Guest

    some confusion here.

    The below code allows me to save a local file to my web server and
    somehow because the field type is file a local file browse button is
    rendered. I'm trying to figure out how to incorporate this code into
    an existing (vb).

    In my code "C:\Uploads\uploadedfile.txt" is dynamcially set to a value
    pulled from a textbox, but how do automatically get browse window to
    come up when I call a subroutine Does have an
    asp:file tag type? I'm looking to always select the local file via a
    browse window, and don't want a local file field to be visible.

    Thanks in advance!

    <%@ Page Language="VB" %>
    <script runat="server">

    Sub SubmitButton_Click(Source As Object, e As EventArgs)
    If Not (File1.PostedFile Is Nothing) Then
    Span1.InnerHtml = "Upload Successful!"
    Catch ex As Exception
    Span1.InnerHtml = "Error saving file <b>C:\\" & _
    File1.Value & "</b><br>" & ex.ToString()
    End Try
    End If
    End Sub

    <form runat="server" enctype="multipart/form-data">
    Select a file to upload:<br />
    <input type="file" id="File1" runat="Server">
    <input type="submit" id="Submit1" runat="Server"
    value="Upload File" OnServerClick="SubmitButton_Click">
    <span id="Span1" runat="Server" />
    jason, Nov 5, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.