[Haskell-cafe] Problem with Text.XHtml.Strict.Formlets.file on Mac OSX

Chris Eidhof chris at eidhof.nl
Wed Sep 23 09:46:40 EDT 2009


OK, the trick is to set the attribute enctype="multipart/form-data" on  
the form whenever your form contains a file upload item. Using the  
third parameter you can detect if this is the case. This is typical of  
using file-upload fields in web programming and independent of the  
formlets. It's also covered in the Happstack tutorial [1] and in the  
HTML form spec [2].

Good luck,

-chris

[1] http://tutorial.happstack.com/tutorial/file-uploads
[2] http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4

On 23 sep 2009, at 15:35, Colin Adams wrote:

> I'm not sure, but the other components of the form work (before I
> added the file bit, that is), so they will all be using the same
> method.
>
> I'm using a generic form-handling function named withForm that I got
> from one of the examples - this code appears to ignore the third
> component of the tuple.
>
> Note that I don't really understand all of this yet.
>
> 2009/9/23 Chris Eidhof <chris at eidhof.nl>:
>> Hey Colin,
>>
>> The code looks OK to me. Are you sure you are setting the right  
>> method for
>> your form? It's the third component of the tuple returned by the
>> runFormState.
>>
>> Thanks,
>>
>> -chris
>>
>> On 22 sep 2009, at 08:56, Colin Adams wrote:
>>
>>> I'm writing a form that involves picking a file to upload, and so  
>>> uses
>>> Text.XHtml.Strict.Formlets.file. The form displays OK, but when I
>>> click the Browse button, and select a file from the dialog (no  
>>> matter
>>> what the file type), and then click on the Submit button, I get an
>>> error:
>>>
>>> "fval[2] is not a file"
>>>
>>> I haven't added any validation yet.
>>>
>>> The generated html looks ok to me:
>>>
>>> <input type="file" name="fval[2]" id="fval[2]">
>>>
>>> This is on my laptop running Mac OSX. I can't test it on Linux  
>>> until I
>>> get home at the weekend, so I don't know if I've made a silly  
>>> error in
>>> my coding, but it is very simple:
>>>
>>> imageInputForm = F.plug (\xhtml -> X.p << (X.label << "Image file:")
>>> +++ xhtml) F.file
>>>
>>> Are there any known problems with the file formlet? Might it be OSX
>>> specific?
>>> --
>>> Colin Adams
>>> Preston,
>>> Lancashire,
>>> ENGLAND
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
>
>
> -- 
> Colin Adams
> Preston,
> Lancashire,
> ENGLAND



More information about the Haskell-Cafe mailing list