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

Parse form field?

Hi everyone,

Not a programmer, just need a little help.... I have a form with a
type="file" field, which uploads the file to the server (using
ColdFusion).

is there a way to parse the type="file" field to extract the file name
and store it into a DB when the form gets submitted?

Any help is appreciated. Thx!
Jul 23 '05 #1
3 4685
Mags wrote:
Hi everyone,

Not a programmer, just need a little help.... I have a form with a
type="file" field, which uploads the file to the server (using
ColdFusion).

is there a way to parse the type="file" field to extract the file name
and store it into a DB when the form gets submitted?

Any help is appreciated. Thx!


Yes, but you would have to use server-side technology such as Perl, PHP,
ASP, JSP, ColdFusion, etc.

The exact solution depends on what database and server-side technology you
have available to you.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2
Actually, I am using CF - but I just figured it out:

STEP 1: grabbing the info from the 4th form element....

<script language="JavaScript">
<!--
function getValue(otherElement){
var path_name = (otherElement.form.elements[4].value);
window.document.myForm.the_file.value = path_name;
}
// -->
</script>

STEP 2: hidden file where this value will be passed to...

<form name="myForm" etc.>
<input type="hidden" name="the_file">

STEP 3: the submit button pushes the value into the hidden field....

<input type="submit" onClick="getValue(this);" name="Set"
value="Submit">
</form>

ColdFusion then can do all the database (which by the way is MS SQL) and
submission. No idea if this is the best way to do it but it works (after
testing for a couple hours). Maybe the code will help someone else. Now
I just need to run some string functions on the 4th form element to
extract the file name...

Thanks for responding!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Mags wrote:
Actually, I am using CF - but I just figured it out:

STEP 1: grabbing the info from the 4th form element....

<script language="JavaScript">
The "type" attribute is required since HTML 4 and sufficient:

<script type="text/javascript">
<!--
This is obsolete, you can/should omit it and its closing counterpart.
[...]function getValue(otherElement){
var path_name = (otherElement.form.elements[4].value);
window.document.myForm.the_file.value = path_name;
}
[...]
<input type="submit" onClick="getValue(this);" name="Set"
value="Submit">
</form>

ColdFusion then can do all the database (which by the way is MS SQL) and
submission. No idea if this is the best way to do it but it works (after
testing for a couple hours).
It works if client-side script support is present, the DOM of the UA
provides means to retrieve the value of an input[type="file"] element
and if timing issues do not prevent the form from being submitted too
early, otherwise it does not work at all.
Maybe the code will help someone else.
I doubt that.
Now I just need to run some string functions on the 4th form element to
extract the file name...


It would be

var filename =
document.forms["myForm"].elements[3].value.replace(/.*[\\/]/, "");

But as you do have ColdFusion available, why do you not do the
whole thing server-side? It would be the only reliable solution.
PointedEars
Jul 23 '05 #4

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

Similar topics

6
by: Dave Kuhlman | last post by:
Suppose that I have content that looks like what I've included at the end of this message. Is there something in the standard Python library that will help me parse it, break into the parts...
11
by: Karim | last post by:
I am looking for the easiest way to parse a float number. X.Y where X=>0 and X <=5 and Y = 0 or Y = 5 e.g. the number should be one of the following 1 1.0 1.5 2 2.0 2.5 etc. I tired using...
6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
3
by: Ken Bush | last post by:
How can I write an update query that removes part of a field? Like if I have a field with values such as 8/3/68 (a birthday obviously) and I need to put values in a new column but I need...
2
by: News charter | last post by:
I have a form that I need to pass the sales tax. Works great if sales tax is an interger. When I try to parse the sales tax with decimal place with Int32.Parse method I get exception. The...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
3
by: Jeremy Chapman | last post by:
I've created a custom control which outputs html at runtime like <span id="controlid" value="myvalue"></span>. On my page I have javascript that changes the value of the value attribute. On post...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
14
by: jmDesktop | last post by:
I have a food menu. Each area, like beverages, grill, etc. have items under them, Coke, Tea, Coffee would be under beverages for example. I want to add a new drink to beverages. In my database...
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: 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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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:
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.