Re: enctype=multipart/form-data on destination page, originating page, or both?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



thanks for your response bruce. responses to your response below:

there is no post/form logic.

the attributes in my form tag are changed dynamically as the form loads
because
the site.master page has a <form runat=server> tag and all the child
pages of the
site.master page load with a <form id=aspnetForm> tag. so, putting a
from tag
inside a form tag inside a form tag is a "no", "no"... "no". as a
result, i am changing the aspnetForm tag when the page loads to look
like the below:

window.onload = function() {

var theForm = document.getElementById('aspnetForm');
theForm.setAttribute('enctype', 'multipart/form-data');
theForm.setAttribute('action', 'server_upload.aspx');
theForm.setAttribute("onsubmit", "return
callToServer('aspnetForm')");
theForm.setAttribute('target', 'RSIFrame');

}

its ugly, but it works.

if a filecontrol is on the form, asp.net renders the multipart type.

thats my bad, i was using a control but not any more.

HttpResponse will only parse the files if the post data has the
multipart content header.

maybe i misunderstand, but i am not using "ajax" (xmlhttprequest) here.
as far as i
know, that can't be done with file uploads. what i am doing here is
passing the file
upload params through the rendered iframe to the server_upload.aspx
page where
the server logic acts on those values.

this is where things start to fail. the httpfilecollection in the
server code is always
length=0 so i am certainly doing something wrong. i am not sure why i
cant access
the passed url string but i originally thought that it had something to
do with how i am
handling the multipart/form-data declaration. hence my original
question (and, maybe
this is what you mean by the above comment).

i am also unclear how to get a response back to the client since this
is not a straight xmlhttp request/response. i have the below script on
the server_upload.aspx page but
this doesn't allow for passing variables from the server:
<script type="text/javascript">window.parent.handleResponse()</script>

sorry for all the verbage but i am really stumped here. if you prefer,
i can post or email
my client_upload.aspx and server_upload.aspx code if you don't mind
taking a look.

thanks for the help.
peter


if the posted data is too large, the connection is closed, and the
asp.net does not continue processing.

if you use session, requests are serialized.

-- bruce (sqlwork.com)


pbd22 wrote:
thanks for your response Laurent.

then maybe this is my problem? i have a client - client_upload.aspx
that has all the javascript and the HTML. but, i have a function call
that sends the url string through
a hidden iframe to the server page (server_upload.aspx). the form tag
on the client has an action of action="server_upload.aspx" inaddition
to the enctype=multipart/form-data. the response from
server_upload.aspx is sent back to client_upload.aspx.

so, that is why i was wondering if both forms need the multipart
enctype. should i be doing everything on the same aspx page - client
and server processing? this seems to disgree with what i have read
online.

FYI - here is the the onsubmit function of the client_upload.aspx form.

function callToServer(theFormName) {

if (!document.createElement) {
return true
};

var IFrameDoc;

var URL = 'server_upload.aspx' + buildQueryString(theFormName);

if (!IFrameObj && document.createElement) { //1
// create the IFrame and assign a reference to the
// object to our global variable IFrameObj.
// this will only happen the first time
// callToServer() is called
try { //2
var tempIFrame=document.createElement('iframe');
tempIFrame.setAttribute('id','RSIFrame');
tempIFrame.style.border='0px';
tempIFrame.style.width='0px';
tempIFrame.style.height='0px';
IFrameObj = document.body.appendChild(tempIFrame);

if (document.frames) { //3
// this is for IE5 Mac, because it will only
// allow access to the document object
// of the IFrame if we access it through
// the document.frames array
IFrameObj = document.frames['RSIFrame'];
} // end 3
} // end 2
catch(exception) { // 3
// This is for IE5 PC, which does not allow dynamic creation
// and manipulation of an iframe object. Instead, we'll fake
// it up by creating our own objects.
iframeHTML='\<iframe id="RSIFrame" style="';
iframeHTML+='border:0px;';
iframeHTML+='width:0px;';
iframeHTML+='height:0px;';
iframeHTML+='"><\/iframe>';
document.body.innerHTML+=iframeHTML;
IFrameObj = new Object();
IFrameObj.document = new Object();
IFrameObj.document.location = new Object();
IFrameObj.document.location.iframe =
document.getElementById('RSIFrame');
IFrameObj.document.location.replace = function(location) { //4
this.iframe.src = location;
} // end 4
} // end 3
} // end 2


Laurent Bugnion wrote:
Hi,

pbd22 wrote:
hi.

could somebody tell me, when uploading a file, i know the form where
the upload component is must
have enctype=multipart/form-data but, is the same true for the form
with the server code to handle the upload?

thanks.
I don't understand what you mean. There is one form only, it's on the
ASPX page, get sent to the client, and then the same form get sent back
to the server.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch


.



Relevant Pages

  • Re: Any hints why Firefox wont honor target=_top?
    ... The iFramed page has a JavaScript in it, that pulls a form from the remote server, and uses a form button to have the user interact with it. ... In FireFox, the content is displayed in the iFrame, which of course is unreadable. ... I have target tags on both the iFrame tag and the framed page. ... I believe the problem is specific to the form button, wherein FireFox does not honor the "target" tag in the surrounding files for form buttons. ...
    (alt.html)
  • Any hints why Firefox wont honor target=_top?
    ... I have an iFrame created to get around a flakey server that sends content to ... I have target tags on both the iFrame tag and the framed page. ...
    (alt.html)
  • Re: Calling Javascript from a vb.net Method - Confirm()
    ... I simple way to store the response on client and have it on server is to use ... On client you can access to the value of this tag with ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: enctype=multipart/form-data on destination page, originating page, or both?
    ... the sample code just creates an iframe, ... a hidden iframe to the server page. ... the form tag ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: quote error in response.write
    ... Common causes for this error are ... when the response is modified by calls to Response.Write, ... filters, HttpModules, or server trace is enabled. ... the tag. ...
    (microsoft.public.dotnet.framework.aspnet)