file field in ASP page

This is a discussion on "file field in ASP page" within the Classic ASP section. This forum, and the thread "file field in ASP page 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 Dec 5th, 2005, 09:28
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
file field in ASP page

Hi,

I am having a problem with file upload in ASP pages. ASP page breaks when I insert a "file field" input and form enctype is "multipart/form-data". Then I saw this: http://www.experts-exchange.com/Web/..._21600503.html which explains whiy.. However, through my search for another answer, I came by this: http://www.motobit.com/util/upload/old-upload.asp and this http://64.39.14.230/ig-asp/common/news.asp and other more without progress bars.

Any ideas why they can have the "file field" and form enctype="multipart/form-data" and not break ASP pages?

Any light shed on this matter is greatly appreciated.

Thanks
Reply With Quote

  #2 (permalink)  
Old Dec 5th, 2005, 09:33
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

sorry, the first link should be : http://www.macromedia.com/cfusion/kn...fm?id=tn_16542

Thanks again.
Reply With Quote
  #3 (permalink)  
Old Dec 5th, 2005, 19:21
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

.... and you are using dreamweaver?
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #4 (permalink)  
Old Dec 5th, 2005, 23:34
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Yup.. Im am using dream weaver to develop the page. If ever Dreamweaver is the one causing the problem, can you recommend me other tool that I can use to develop my ASP page?

Thanks....
Reply With Quote
  #5 (permalink)  
Old Dec 6th, 2005, 00:29
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

I always use notepad....

Seriously though, I never use tools like dreamweaver.... or any other tools that mess with code. I prefer to be 100% control of all code so therefore notepad is my tool of choice.... obviously though it is a prerequisite that you know ASP pretty well.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #6 (permalink)  
Old Dec 6th, 2005, 00:37
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Thanks for the quick reply Rob.. Notepad?! T.T Sorry but I am not an expert in this field.. But I will try right away. I will reply as quickly as possible hoping that you will guide e through this.

Thanks again!
Reply With Quote
  #7 (permalink)  
Old Dec 6th, 2005, 00:41
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

No worries....

It seems yiou really need to get your feet wet with ASP.... I can recommend a few good books that could easily give you the knowledge you need to do this...... One book I learned with many many moons ago, helped me learn ASP in a week.... after another week pulling existing applications to pieces I knew ASP to an advanced level (We are taking 7 years (ish) ago now... lol)
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #8 (permalink)  
Old Dec 6th, 2005, 01:12
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Rob,

Hi. I cant still get this site working. I used Notepad in altering some code in the .asp page.. but it still breaks. I then removed the enctype="multipart/form-data" then the pages display successfully. But the thing is, I cannot include files in my form submission when form enctype is not "multipart/form-data" and if there are no file fields on the form.

I can give you the pages that I am working on but it requires connection to a MSSQL database on this server.

I reall appreciate your help.

Thanks.
Reply With Quote
  #9 (permalink)  
Old Dec 6th, 2005, 01:24
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

Like I said.... you will need to know ASP pretty well.
You cant just change dreamweavers code because it's form handling stuff will need changed too.... no, you are going to need to learn ASP I think. I doubt many ASP developers would even want to try and hack apart the spagetti of rubbish dreamweaver produces.... although, you can post the code in theis thread (in code tags please) and we'll maybe take a look.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #10 (permalink)  
Old Dec 6th, 2005, 02:08
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

I dont think it is syntax that creates the error. Well, anyway, here it is(trimmed):
Thanks again!

HTML: Select all
<!-- #include file="include/config.asp" -->
 
<%
openConn()
 
Set objCommand = CreateCmd("sp_project_read")
Set RsProject = objCommand.Execute()
Set objCommand = Nothing
%>
 
<html>
<head>
<title>Drawing Tracking Module - Drawing Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/style.css" type="text/css"> 
<link rel="stylesheet" type="text/css" media="all" href="calendar-brown.css" title="summer" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-green.css" title="green" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-blue.css" title="winter" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-1.css" title="win2k-1" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-2.css" title="win2k-2" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-cold-1.css" title="win2k-cold-1" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-cold-2.css" title="win2k-cold-2" />
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-system.css" title="system" />
<link rel="stylesheet" href="css/style.css" type="text/css"> 
 
<script type="text/javascript" src="calendar.js"></script>
 
<script type="text/javascript" src="lang/calendar-en.js"></script>
 
<script type="text/javascript">
 
var oldLink = null;
function setActiveStyleSheet(link, title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
if (oldLink) oldLink.style.fontWeight = 'normal';
oldLink = link;
link.style.fontWeight = 'bold';
return false;
}
 
function selected(cal, date) {
cal.sel.value = date;
if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
cal.callCloseHandler();
}
 
function closeHandler(cal) {
cal.hide();
cal.destroy();
calendar = null;
}
 
function showCalendar(id, format, showsTime) {
var el = document.getElementById(id);
if (calendar != null) {
calendar.hide(); 
} else {
var cal = new Calendar(true, null, selected, closeHandler);
if (typeof showsTime == "string") {
cal.showsTime = false;
cal.time24 = (showsTime == "24");
}
calendar = cal;
cal.setRange(1900, 2070);
cal.create();
}
calendar.setDateFormat("%m/%d/%Y");
calendar.parseDate(el.value);
calendar.sel = el; 
 
calendar.showAtElement(el.nextSibling, "Br");
 
return false;
}
 
var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;
 
function isDisabled(date) {
var today = new Date();
return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}
 
function flatSelected(cal, date) {
var el = document.getElementById("preview");
el.innerHTML = date;
}
 
</script>
</head>
 
<script type="text/javascript" language="JavaScript"> 
 
function save()
{
var ok_flag = true;
 
if (document.callfrm.project_id.value == '') {
alert("Please enter project number.");
document.callfrm.project_id.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.mark.value == '') {
alert("Please enter mark.");
document.callfrm.mark.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.qty.value == '') {
alert("Please enter quantity.");
document.callfrm.qty.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.section_size.value == '') {
alert("Please enter section size.");
document.callfrm.section_size.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.grade.value == '') {
alert("Please enter grade.");
document.callfrm.grade.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.length.value == '') {
alert("Please enter length.");
document.callfrm.length.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.mass.value == '') {
alert("Please enter mass.");
document.callfrm.mass.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.source.value == '') {
alert("Please enter source.");
document.callfrm.source.focus();
ok_flag = false;
return false;
}
 
if (document.callfrm.seq_no.value == '') {
alert("Please enter sequence number.");
document.callfrm.seq_no.focus();
ok_flag = false;
return false;
}
 
if (ok_flag == true) { 
document.callfrm.submit();
document.callfrm.btnsave.disabled = true;
} 
}
 
function textCounter(field, countfield, maxlimit) { 
if (field.value.length > maxlimit) // if too long...trim it! 
field.value = field.value.substring(0, maxlimit); 
// otherwise, update 'characters left' counter 
else 
countfield.value = maxlimit - field.value.length; 
} 
 
function showDialog(targetControl) {
var dlgBrowse = new ActiveXObject("MSComDlg.Commondialog");
dlgBrowse.Filter = "PDF Files|*.pdf|All Files|*.*";
dlgBrowse.FilterIndex = 1;
dlgBrowse.Flags = 0x200 | 0x1000 | 0x80000;
dlgBrowse.MaxFileSize = 512; 
 
dlgBrowse.ShowOpen();
 
if (dlgBrowse.Filename == "")
return false;
else
targetControl.value = dlgBrowse.Filename;
return true;
}
 
function detectIEclient()
{
var ua = window.navigator.userAgent;
var msie = ua.indexOf ( "MSIE " );
 
alert(msie);
 
if ( msie > 0 ) // If Internet Explorer, return version number
return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
else // If another browser, return 0
return false;
 
}
</script> 
 
<form action="p_drawing_save.asp" enctype="multipart/form-data" method="post" name="callfrm">
<table width="380" cellpadding="0" cellspacing="0" style="BORDER-RIGHT: #990000 2px solid; BORDER-LEFT: #990000 2px solid; BORDER-BOTTOM: #990000 2px solid; BORDER-Top: #990000 2px solid" bgcolor="#FFDB8B" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" class="Label1" bgcolor="#990000"><div align="center">DRAWING INFORMATION</div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="Label2" height="10"></td>
<td width="56%"></td>
</tr>
<tr >
<td class="Label2" height="20"><div align="right">Project Number: </div></td>
<td class="Label2"><select name="project_id" class="frmselectfld">
<option>--Select One--</option>
<%
RsProject.movefirst
do while not RsProject.eof 
%>
<option value="<%=RsProject("project_id")%>" <%if trim(project_id) = trim(RsProject("project_id")) then response.write "selected" end if%>><%=RsProject("project_id")%></option>
<% RsProject.movenext
loop 
%>
</select></td>
</tr>
... some text fields ...
<tr >
<td class="Label2" height="20"><div align="right">Approval 1 Drawing: </div></td>
<td class="Label2" valign="baseline"><input type="file" name="approval1_drawing" id="approval1_drawing" size="20" class="frmtextfld"></td>
</tr>
... some more input fields (4)
... some text fields again ...
<tr >
<td height="5" colspan="2" class="Label2"></td>
</tr>
<tr >
<td height="5" colspan="2" class="Label2"><table width="100%" border="0" align="center">
<tr> 
<td colspan="2">
<div align="center" class="Label2">
<input name="btnsave" type="button" value=" Save " onClick="javascript:save();" class="frmsubmitbtnsmall">
<input type="reset" name="Reset" value=" Clear " class="frmsubmitbtnsmall">
</div>
</td>
</tr> 
</table></td>
</tr>
<tr >
<td height="10" colspan="2" class="Label2"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%
closeConn()
%>
</body>
</html>

Last edited by Rob; Dec 6th, 2005 at 07:17.
Reply With Quote
  #11 (permalink)  
Old Dec 6th, 2005, 07:16
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

Next time please use [code][/code] tags for posting code... it's much tidier... I edited your post and will look over it later.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #12 (permalink)  
Old Dec 6th, 2005, 08:59
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Apologies. I didn't know how to use that.. I'm new to joining forums actually. Please bear with my ignorance.

Thanks again Rob.
Reply With Quote
  #13 (permalink)  
Old Dec 6th, 2005, 10:35
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

No worries.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #14 (permalink)  
Old Dec 6th, 2005, 13:03
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbramz
Re: file field in ASP page

.....im not even going to attempt picking that out

what do you need? an upload? im sure i cn send u a premade upload ive done..give me some more info tho...it might not be subatle for what you need....

Last edited by benbramz; Dec 7th, 2005 at 08:29.
Reply With Quote
  #15 (permalink)  
Old Dec 7th, 2005, 00:56
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Hi benbramz,

I made a simple ASP page but very simple though (from the HTML version of an upload class i downloaded made by Jacob "Beezle" Gilley). The page did not break! I will still try to add some more fields, CCSs, and ASP codes in this page and see if it will show the same thing.

Anyway, the site I am coding is, (1) It is an ASP page where I tried to insert 5 file fields into it, (2) it has ASP codes inserted everywhere in the HTML code, (3) breaks when these are satisfied: (a) enctype of form is "multipart/form-data" (b) there are existing file fields in the form.

Any help is greately appreciated.

Thanks!

Note: What I mean with break is: the ASP page with file fields displays but when I submit the form to the next ASP action page, the next ASP action pages are not executed or displayed.
Reply With Quote
  #16 (permalink)  
Old Dec 7th, 2005, 08:17
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

I presume you know that when using multipart/form-data on a form, you cannot then use request.form on the next page.... it just doesnt work.

You can only get to the form fields by querying the upload object / class you are using.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #17 (permalink)  
Old Dec 7th, 2005, 23:17
New Member
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file field in ASP page

Hi Rob and benbramz!

Thanks for all your help!I finally got it working!

"I presume you know that when using multipart/form-data on a form, you cannot then use request.form on the next page" - Rob

Actually, I dont know! lol Thanks for the info anyway.

Thank you for helping a newbie like me. Apologies for my ignorance.
Reply With Quote
  #18 (permalink)  
Old Dec 7th, 2005, 23:23
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbramz
Re: file field in ASP page

hehe anytime
Reply With Quote
  #19 (permalink)  
Old Dec 8th, 2005, 11:46
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: file field in ASP page

most welcome!
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Tags
file, field, asp, page

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
[SOLVED] getting page file name. KillerChutney PHP Forum 6 Nov 12th, 2007 16:17
Links in a txt file not showing in dynamic text field Darren600 Flash & Multimedia Forum 8 May 9th, 2007 15:48
How to link HTML page to CSS file winwin Web Page Design 18 Dec 21st, 2006 09:46
Working with Form 'file field' data in ASP. daryl Classic ASP 3 Jun 24th, 2006 20:22
File Field issue! SimpleGuy Classic ASP 4 May 16th, 2005 17:59


All times are GMT. The time now is 00:04.