473,670 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.PostedFil e.FileName
pos = s1.LastIndexOf( "\") + 1
s2 = s1.Substring(po s)
file1.PostedFil e.SaveAs("C:\In etpub\wwwroot\x xxxx\images\mac hines\" & s2)
file_uploaded.T ext = "<strong>" & s2 & " has been uploaded!</strong>"
' Add a new userRole to the database
Dim MachID = Session("select edMachineID")
Dim admin As New ASPNETProduct.m achinedb
admin.AddMachIm age(MachID, s2)
--

_______________ _______
David Fetrow
HelixPoint LLC.
http://www.helixpoint.com
da***@helixpoin t.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***@helixpoin t.com
_______________ _______
Nov 17 '05 #1
1 1711
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**@helixpoin t.com> wrote in message
news:#z******** *****@TK2MSFTNG P12.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.PostedFil e.FileName
pos = s1.LastIndexOf( "\") + 1
s2 = s1.Substring(po s)
file1.PostedFil e.SaveAs("C:\In etpub\wwwroot\x xxxx\images\mac hines\" & s2)
file_uploaded.T ext = "<strong>" & s2 & " has been uploaded!</strong>"
' Add a new userRole to the database
Dim MachID = Session("select edMachineID")
Dim admin As New ASPNETProduct.m achinedb
admin.AddMachIm age(MachID, s2)
--

_______________ _______
David Fetrow
HelixPoint LLC.
http://www.helixpoint.com
da***@helixpoin t.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***@helixpoin t.com
_______________ _______

Nov 17 '05 #2

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

Similar topics

0
1270
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 max_execution_time=1000 -q /root/projects/ftptest/ftptester.php <?php // ftptester.php:
18
9096
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 data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts running when the file is not completely
2
3862
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 after the file is uploaded to server which wastes the bandwidth so what i want to check is that the server first checks the size of file to upload and if it is o.k. then and then only the file will be uploaded..
4
2599
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 file size (client or server side), so that error doesn't occur? Thanks --Dietrich
8
20188
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 FileUpload1.PostedFile.ContentLength > ConfigurationManager.AppSettings("MaxVideoUploadSize") Then lblErr.Text = "File needs to be > 0 bytes and less than " & ConfigurationManager.AppSettings("MaxVideoUploadSize") / 1000000 & " MB." Exit Sub
2
2284
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
30199
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 trying to upload file size more than 4MB then just display a message that file size is too big and can't be uploaded. thanks
2
1859
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 enable Zend on their php. I would like to have a way to check for a file to be a jpg or gif file in another way.
10
3840
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 c:/sample.bmp now i manually edit the file input box as c:/sample.gif and i upload this one. Now i want to check the orignial file ext.. is there any way in javascript or php.....
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.