I’ve got an HTML file on my phone, and would like to view it. But Firefox on Android has neither a menu entry “Open File”, nor does using the file:// method work, nor is any app associated with the .html file extension.

BTW, Chrome suffers from the same problem. And it is not an issue with the file, it works when opened via the https:// method from my home server.

Why, oh why, can’t I open a local file on Android?

  • mvirts@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    5 days ago

    The Android way to do this is to open the file from some sort of file browser app and select Firefox from the list of apps that registered for that file type. Unfortunately it looks like Firefox doesn’t register itself for html files.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    4
    ·
    5 days ago

    I was pretty irritated when I noticed that myself. I’m guessing that there’s some form of attack or class of attacks that this is designed to avoid (e.g. IIRC a webpage opened from a file:// URL can have Javascript access files via file:// as well, and I imagine theoretically could upload them somewhere or something), but it sure is goddamn obnoxious.

    My guess is that you can probably fire up a local HTTP server on your phone and view it via that. I don’t think that Android phones set up a firewall by default, so have it listen on a loopback address, like 127.0.0.1.

    Based on this, you can use a file manager to share the HTML file with Firefox.

  • Darkassassin07@lemmy.ca
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    edit-2
    5 days ago

    It’s clunky, but I can open files in firefox by using a file browser app (I use x-plore), selecting ‘open with’, then selecting firefox. Sometimes it’s not in the list, but there’s a selector for what type of file (text, video, audio, ‘*’). ‘*’ lists all the apps.

    Sometimes stuff still refuses to open, but things like pdfs and html files usually work