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

P

pbd22

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.
 
L

Laurent Bugnion

Hi,
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
 
P

pbd22

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
 
B

bruce barker

its still not clear what you are doing. the sample code just creates an
iframe, there is no post/form logic.
tag

couple of things to know.

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

HttpResponse will only parse the files if the post data has the
multipart content header. it doesn't care about what the response looks
like.

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)

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 said:
Hi,

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
 
P

pbd22

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)

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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,696
Latest member
BarbraOLog

Latest Threads

Top