472,789 Members | 1,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 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 4656
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.