473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to check for a file before I upload??

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
da***@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
da***@helixpoint.com
______________________
Nov 17 '05 #1
1 1684
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" <da**@helixpoint.com> wrote in message
news:#z*************@TK2MSFTNGP12.phx.gbl...
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
da***@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 da***@helixpoint.com
______________________

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Google Mike | last post by:
Had to write something similar to this for my office. You can adapt to your use. I just put it on a chron job for every 15 minutes. My bash script did: #!/bin/bash php -d...
18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
2
by: vishal | last post by:
hi is there anyway that i can check the size of file on client side before uploading file to server???? suppose the user uploads file of 10 mb then the server will know the size is 10 mb...
4
by: lawrence | last post by:
Using <INPUT type"file" runat="server"> to upload a file. When the file size is too large I get a "page cannot be display" error. Thats cool I'm down with that. But is there a way to check for...
8
by: VB Programmer | last post by:
I am using a FileUpload control (ASP.NET 2.0). How do I check the length of the file in bytes BEFORE I let them upload it? I believe my code checks now AFTER... If...
2
by: yonthebeach | last post by:
hi, i have an upload mechanism on my website and want to check the filesize on the client size. is this possible? thanks yavuz bogazci
3
by: puja | last post by:
hi all, In asp.net 2.0 there is a limit on file size upload of 4MB. I know this limit can be increased in web.config file. Is there any way to check the file size before upload ? if user is...
2
by: Geoff | last post by:
Hi Previously I was able to check for an uploaded file to be a jpg or a gif by using the exif_imagetype() function. I had to change from hosting provider and the new one doesn't want to...
10
by: maheswaran | last post by:
Hi, I want to check the extension of uploaded file. I upload the bmp image using file property. Now i am going to edit the file upload text as bmp file into gif... example : i upload...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.