Working with Form 'file field' data in ASP.

This is a discussion on "Working with Form 'file field' data in ASP." within the Classic ASP section. This forum, and the thread "Working with Form 'file field' data in ASP. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 19th, 2006, 16:25
New Member
Join Date: Jun 2006
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Working with Form 'file field' data in ASP.

I am relatively new to ASp and I'm sure this is a simple problem and I'm just missing something simple.
----------------------
BACKGROUND:
I have got a form, with a few text fields and 3 'file fields' used to upload images.(this works fine)

All I want to do is get the value of each of the 'file fields'.
----------------------
MY QUESTION:
How do you get the value of a 'file field'?
Reply With Quote

  #2 (permalink)  
Old Jun 19th, 2006, 17:03
New Member
Join Date: Jun 2006
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Working with Form 'file field' data in ASP.

Could this worK?

If I used the javascript below to get the value of the form field? I could run it on page unload.

<script type="text/javascript">
var obj = document.getElementById('filefield1');
</script>


Just thinking, it probably wont work but I will look into it.
Reply With Quote
  #3 (permalink)  
Old Jun 24th, 2006, 16:01
New Member
Join Date: Jun 2006
Location: wednesbury
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Working with Form 'file field' data in ASP.

Quote:
Originally Posted by daryl
Could this worK?

If I used the javascript below to get the value of the form field? I could run it on page unload.

<script type="text/javascript">
var obj = document.getElementById('filefield1');
</script>


Just thinking, it probably wont work but I will look into it.
no it wont work....well it might, but why use javascript!

you can simly call the forum field -

Code: Select all
field1 = request.form("field1")
response.write field1
where field1 is the name of your input box...
Reply With Quote
  #4 (permalink)  
Old Jun 24th, 2006, 20:22
New Member
Join Date: Jun 2006
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Working with Form 'file field' data in ASP.

Actually you cant just call it. It does not work for file upload fields.

It works for all other form fields, but not for file upload fields.


The solution:

1.Put this javascript in the head.
<script language="JavaScript"><!--
function getExtension(value) {
return value.substring(value.lastIndexOf() + 1,value.length);
}
//--></script>


2.Put this 'onclick' script on the forms submit button.
<input name="submit" type="submit" value="Submit" onClick="document.MyForm.input1.value =(getExtension(this.form.FILE1.value));"/>

3.You also need a hidded field called in this case, 'input1'


How it works:

When the submit button is clicked, using the javascript function it takes the file field data and inserts it into a pre created hidden form field which you can then reference by name.

I could then tell which image upload fields were empty and then alter the path information after the image upload but before the path was entered into the database.
Reply With Quote
Reply

Tags
working, form, file, field, data, asp

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Links in a txt file not showing in dynamic text field Darren600 Flash & Multimedia Forum 8 May 9th, 2007 15:48
Creating A new Data BAse from .txt file JamieH Databases 3 Jan 28th, 2006 23:26
file field in ASP page lameneural Classic ASP 18 Dec 8th, 2005 11:46
Add a form field csa Web Page Design 8 Nov 23rd, 2005 20:33
File Field issue! SimpleGuy Classic ASP 4 May 16th, 2005 17:59


All times are GMT. The time now is 20:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43