Webspeed Issue Using Form With Enctype="multipart/form-

Posted by Marco Mendoza on 02-Mar-2016 10:23

OE 10.1C
IIS 6.0
Tested on IE11 and FF 41.0.1

I have the follow webspeed program, called upload2.html:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
thename = GET-VALUE("thename").
{&OUT} "FIRSTHIDDEN:" GET-VALUE("firsthidden") "<br>"
 "NAME:" thename "<br>"
 "SUBMITBUTTON:" GET-VALUE("submitbutton") "<br>"
 "SECONDHIDDEN:" GET-VALUE("secondhidden") "<br>".
<form name="myform" enctype="multipart/form-data" action="upload2.html" method="post">
  <input type="hidden" name="firsthidden" value="yes">
  Name:<input type="text" name="thename" value="`thename`"><br>
  File:<input type="file" name="filename"><br>
  <input type="submit" name="submitbutton" value="LoadFile"><br>
  <input type="hidden" name="secondhidden" value="yes"><br>
-end code-------

I enter Marco to thename input, click on submit button without select a file, I get this:

It does not matter how many times I click on submit button, if I don't
select a file, the program don't get value for "submitbutton" and

If I select a file, and click on submit button, the result is as expected:

WHY? It's a bug, configuration or some kind of expected behavior? Can I fix it?

If I move the "input type file" after the secondhidden input, then it
get the correct values even if I don't select a file.

Thanks in advance for your input,

All Replies

Posted by scott_auge on 02-Mar-2016 13:16

I think this is more of a browser thing than a webspeed thing.

On the browser, there are plug-ins that will state what is being sent out on the post.  Might want to try that to insure it is happening at the browser.

Else the answer you already have.

Posted by Marian Edu on 03-Mar-2016 03:36

There is nothing wrong with the browser(s), webspeed need to parse the request payload and I think the issue might be in the cgi messenger that somehow gets confused about a multi-part post with no file content (content-type seems to be set to binary/octet-stream just no content follows till next boundary). The result is an incomplete variable list that gets sent to the 4gl side.

However that might well be a non issue, you already got the solution to move the hidden fields on top and then act only if you get a submit/file set... the whole point there is to upload file(s), if nothing gets uploaded one my wonder why do you care for the rest of the form fields? :)

Posted by Marco Mendoza on 03-Mar-2016 08:58

Hello Marian,

The example that I posted was simplified, I have a form with several data, with the option to the user for upload some file. The user can choose not to upload file but of course wants to see reflected other changes.

I have 3 workarounds:

1.- Put the input type file at the very last of the form. That could have a problem for usability, design.

2.- Separate the input type file on a different form. Same problem as #1.

3.- This is -at the moment- my final solution: I made a javascript called on form submit; it check for the input type file value, if is empty  removes the input type file tag from the form.

My workaround works fine, but I don't like to use this kind of tricks on the code, that was I was looking for help to the experts ;)    I don't know, maybe some magical IIS setup or a mistake on my code.

On the {&OUT} WEB-CONTEXT:FORM-INPUT   I can see the values correctly, with or without file selected. The odd thing is with  {&OUT} WEB-CONTEXT:GET-CGI-LIST("FORM")  only firsthidden,thename,filename   is show when file is not selected, If im not wrong get-value use that commands.

And you are correct, the content-type on the file when is not selected says:

Content-Disposition: form-data; name="filename"; filename=""

Content-Type: application/octet-stream

This thread is closed