473,385 Members | 1,740 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,385 software developers and data experts.

validating an uploaded file before inserting data in to database

Hello All

I am uploading a file using ASP code. After the user uploads the file, I
would like to be able to open the file and check if the data is in a given
format (comma separated) and also has all the data elements needed (i.e. all
fields are there). Is there a parse routine in asp that would allow me to do
this. The user can upload any type of file as long as I am able to parse it
and determine if the data is of the aforemention type.

Please advise
Jul 19 '05 #1
2 1809
You will have to code this all yourself. You can use the FileSystemObject
to open files and read the contents of them. What I suggest doing is just
starting with a string variable and using it to build your validation.
testString = "asdfj"
If Instr(testString, ",") = 0 Then
REsponse.Write "This isn't a comma delimited file."
Response.End
End If

Ray at work

"Rahul Chatterjee" <ra***@benesysinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello All

I am uploading a file using ASP code. After the user uploads the file, I
would like to be able to open the file and check if the data is in a given
format (comma separated) and also has all the data elements needed (i.e. all fields are there). Is there a parse routine in asp that would allow me to do this. The user can upload any type of file as long as I am able to parse it and determine if the data is of the aforemention type.

Please advise

Jul 19 '05 #2
On Fri, 12 Mar 2004 08:30:55 -0500, "Rahul Chatterjee"
<ra***@benesysinc.com> wrote:
I am uploading a file using ASP code. After the user uploads the file, I
would like to be able to open the file and check if the data is in a given
format (comma separated) and also has all the data elements needed (i.e. all
fields are there). Is there a parse routine in asp that would allow me to do
this. The user can upload any type of file as long as I am able to parse it
and determine if the data is of the aforemention type.


Parsing is somthing you have to code yourself, though there are
obviously a number of functions you can use, such as Split, InStr,
StrComp, etc. Counting comma separated fields could be easy, do a
ReadLine and then a Split at commas and count the elements. You might
even ask the uploader to specify the delimiter from a list, and do the
Split on that delimiter.

If you decide to accept *any* type of input your job gets harder.
Stripping HTML codes, escaping various characters, Trimming spaces and
the like could run hundreds of lines of code, and accepting non-text
files such as an Excel file would further complicate things. You'd
likely have to find a component to do file conversions as part of the
process.

Controlling what the user can supply makes it easier to work with what
you receive.

Jeff
Jul 19 '05 #3

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

Similar topics

1
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising...
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: bissatch | last post by:
Hi, I am trying to write script that is run when a form is submitted. The form contains an image input field and when submitted, the image is uploaded, resized and added as binary information to...
6
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting...
6
by: Mark | last post by:
Hello all, I have the following file.txt storing these kind of values: Name: John Doe E-mail: john@doe.com Phone: 555 865 8901 Address: 71 Huntington Ln. (33444) FL - Delray Beach US Member...
4
by: jack | last post by:
Hi. My project requires to upload the excel file and populate it into the database. By doing so it should also check whether the excel file selected is in the right format. for example if the...
1
by: TYR | last post by:
I have a large dump file that originated in a MySQL db; I need to get it into an SQLite file. Various options are suggested around the web; none of them seem to work (most failing to import the...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
4
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.