How to check for a file before I upload??

Discussion in 'ASP .Net' started by Helixpoint, Jul 18, 2003.

  1. Helixpoint

    Helixpoint Guest

    I upload a file with the following code. Is there a way to check to see if
    the file is currently there before I upload?

    Dim s1 As String
    Dim s2 As String
    Dim pos As Integer
    s1 = file1.PostedFile.FileName
    pos = s1.LastIndexOf("\") + 1
    s2 = s1.Substring(pos)
    file1.PostedFile.SaveAs("C:\Inetpub\wwwroot\xxxxx\images\machines\" & s2)
    file_uploaded.Text = "<strong>" & s2 & " has been uploaded!</strong>"
    ' Add a new userRole to the database
    Dim MachID = Session("selectedMachineID")
    Dim admin As New ASPNETProduct.machinedb
    admin.AddMachImage(MachID, s2)


    --

    ______________________
    David Fetrow
    HelixPoint LLC.
    http://www.helixpoint.com


    Interested in Affordable Email Marketing?
    Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
    If you are interested in becoming a Reseller of HelixPoint products, contact

    ______________________
     
    Helixpoint, Jul 18, 2003
    #1
    1. Advertising

  2. Helixpoint

    bruce barker Guest

    the only way for the browser to send the filename is to post the file. you
    can check on the server side, and display an error if the file exits, but
    the client pays the upload cost (delay) before the message appears.

    if you want the client to check first, send a list of uploaded files to the
    client (say in a hidden field) and have client code triggered by the
    onsubmit event, check if it has already been uploaded. just a couple lines
    of javascript.

    -- bruce (sqlwork.com)


    "Helixpoint" <> wrote in message
    news:#...
    > I upload a file with the following code. Is there a way to check to see if
    > the file is currently there before I upload?
    >
    > Dim s1 As String
    > Dim s2 As String
    > Dim pos As Integer
    > s1 = file1.PostedFile.FileName
    > pos = s1.LastIndexOf("\") + 1
    > s2 = s1.Substring(pos)
    > file1.PostedFile.SaveAs("C:\Inetpub\wwwroot\xxxxx\images\machines\" & s2)
    > file_uploaded.Text = "<strong>" & s2 & " has been uploaded!</strong>"
    > ' Add a new userRole to the database
    > Dim MachID = Session("selectedMachineID")
    > Dim admin As New ASPNETProduct.machinedb
    > admin.AddMachImage(MachID, s2)
    >
    >
    > --
    >
    > ______________________
    > David Fetrow
    > HelixPoint LLC.
    > http://www.helixpoint.com
    >
    >
    > Interested in Affordable Email Marketing?
    > Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
    > If you are interested in becoming a Reseller of HelixPoint products,

    contact
    >
    > ______________________
    >
    >
     
    bruce barker, Jul 19, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lawrence

    Upload file Check file size

    lawrence, Jun 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    9,299
    Craig Deelsnyder
    Jun 10, 2004
  2. Daniel
    Replies:
    1
    Views:
    4,607
    Hermit Dave
    Oct 4, 2004
  3. ad
    Replies:
    1
    Views:
    483
    Cowboy \(Gregory A. Beamer\)
    Mar 6, 2005
  4. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,501
    Bruce Barker
    Aug 3, 2005
  5. Chip

    Capture data before file upload

    Chip, Apr 13, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    451
Loading...

Share This Page