Hi,

Thanks again for your help. I've just finished a rather lengthy reply to Boriss Mejias about the same problem.

I already have the HTML form correctly implemented as you have described. (And I can do the same thing in PHP so the server is set up ok).

However, you say that the server provides the name of the file to the cgi script - I had read that the file itself (presumably as binary data) was passed to the script via STDIN? Also, if the filename was passed to the script I would assume my script would respond with the filename outputted within the HTML fed back to the server?

As Boriss has demonstrated, the script correctly takes data from STDIN and returns it inside HTML code on the command line.

This all seems really confusing: Apache2 works, PHP file upload works, OZ n-queens servlet works (with a form type="text") but file upload won't????

Regards

Mark

On 07/07/10 15:09, Wolfgang Meyer wrote:
To let the user upload a file, you need a two-step process.

First you need an HTML file (possibly generated by a servlet) with a
form with enctype='multipart/form-data' and an input field with
TYPE="FILE". In the "action" attribute you specify which
script/servlet to call after submit.

In the servlet which is called after submit, the web server will
provide the name of the uploaded file as an argument to the script. I
think  the exact details depend on the server.

Google "cgi file upload" for details.
I've never used this with Oz, so I have no idea whether there are any
special pitfalls to avoid.

Cheers,
   Wolfgang

On Mon, Jun 28, 2010 at 5:14 PM, Mark richardson
<[email protected]>  wrote:
Hi,

I wonder if anyone has any experience using Oz for cgi-bin servlets?
I've already successfully created one to give a solution for n-queens for a
submitted board size so I know I can use the facility properly.
What I'm now trying to do is create an 'upload-file' servlet in oz.
As far as I understand the operation of cgi (and I'm no expert!), in the
case of file uploads the data for the file itself is passed via the servlets
stdin.
So, I have the following functor definition:

%%cgi-bin program to accept file uploads
functor
import
   Open
   Application
   OS
define
   StdIn={New Open.file init(name:stdin flags:[read])}
   Env={StdIn read(list:$)}
   Out={New class $
           from Open.file Open.html
        end
    init(name:stdout)}

   %% Print MIME content header
   {Out header}
   {Out tag(html(head(title('Upload files using Oz'))
         body(bgcolor:'#f0f0e0'
              h1('Oz file upload')
              p('The data received was:'#Env)
             )))}
   {Application.exit 0}
end

I'm not currently worried about what actually is received, I'd be happy at
the moment to see anything coming into 'Env'. My problem is that I appear to
be receiving nil. The servlet executes but nothing appears after "The data
received was:".

The difficulty is that I can't see any way of debugging this except
executing it through the web server, so I don't know if 'something' has been
received or not.

Any advice would be gratefully received.

Regards

Mark

--
Mark Richardson MBCS
Email: [email protected]
Skype: mark.richardson.

_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users


--
Mark Richardson MBCS
Email: [email protected]

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to