Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to check for a file before I upload??

Reply
Thread Tools

How to check for a file before I upload??

 
 
Helixpoint
Guest
Posts: n/a
 
      07-18-2003
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

______________________


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-19-2003
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
>
> ______________________
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
distutils - script install check file existence before copy? bwooster47@gmail.com Python 0 03-04-2007 03:22 AM
How to check whether file is browser before submitting the f Santosh R patil Ruby 1 01-30-2007 12:20 PM
Before Sunset & Before Sunrise matt r DVD Video 2 11-25-2004 08:37 AM
check file size before post nicholas ASP .Net 6 10-13-2004 09:52 PM
Check if image file exists before linking to Image object Filip De Backer ASP .Net Web Controls 0 06-11-2004 07:24 AM



Advertisments