How to check for a file before I upload??

  • Thread starter Thread starter Helixpoint
  • Start date Start date
H

Helixpoint

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
(e-mail address removed)

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
(e-mail address removed)
______________________
 
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)
 
Back
Top