def dict_from_cgi_form(cgi_form):
    """
    Convert CGI FieldStorage into a dictionary
    """
    o = {}
    for key in cgi_form:
        res = cgi_form[key]
        try:
            if res.file:
                o[key] = res.file.read()
            else:
                o[key] = res.value
        except:
            o[key] = res
    return o
