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
