Relative HTML paths on Android
Bounty
-
Bounty -
Bounty -
Hello,
First of all, I would like to clarify that I am a novice in HTML.
I would simply like to embed an image in an HTML file that I will then read locally on an Android phone.
So I am just writing:
This of course with the image in question in the same folder as the HTML file.
It works fine on Windows, but on Android, I can't access the image in question. I have tried many other syntaxes and absolute paths, but nothing works. I have also tested on various Android phones with different versions.
Thank you in advance if you have a solution.
Good evening to you.
First of all, I would like to clarify that I am a novice in HTML.
I would simply like to embed an image in an HTML file that I will then read locally on an Android phone.
So I am just writing:
<img src="nom-du-fichier.jpg" alt="txt-de-remplacement">
This of course with the image in question in the same folder as the HTML file.
It works fine on Windows, but on Android, I can't access the image in question. I have tried many other syntaxes and absolute paths, but nothing works. I have also tested on various Android phones with different versions.
Thank you in advance if you have a solution.
Good evening to you.
8 answers
-
Hello,
It's the simplest situation: HTML file and image in the same folder.
Objectively, there’s no reason this shouldn’t work unless there is a syntax error, but since it works on Windows, I doubt it.
That being said, in your example, the opening quote is missing at src="filename.jpg"...
Are the files placed in a regular folder (documents, downloads ...)?
And just in case, is the filename in the HTML strictly the same as in the folder, including uppercase and lowercase letters? -
Hello,
Yes, I tried to simplify things as much as possible to identify the problem. But it seems that it’s not enough...
Regarding the quotation marks, that was my mistake in the post; they are indeed present in the HTML file.
As for the files, I placed them in a folder that is situated at the root of the internal memory of the phone. For the tests on Windows, everything is simply placed in a folder on the desktop.
Yes, the names are exactly the same, and to avoid any other errors, I did tests with names in lowercase only and without special characters or spaces.
Thank you for your help. -
-
Hello,
On Android (or iOS for that matter...) it's not like on Windows.
The permissions for accessing folders/files on the phone are very restrictive...
The internet browser does not have access to just any file on the phone....
At most, you should try to place your HTML file and your photos in a folder (usually accessible to the browser) which would be the "downloads" or the photo gallery...
After that... for what concerns the path to indicate... now that's a good question...
--
.
Best regards,
Jordane-
This is the avenue I suggested exploring in my first response and that I forgot to emphasize in the last one: I agree with Jordane that it's a problem of rights regarding the files!
Your HTML should simply look like this:<!DOCTYPE html> <html> <body> <img src="my-image.jpg" alt="my alternative text"> </body> </html>
-
-
Thank you for your incredibly quick responses!
The code is like the city RoMa_31, only the name of the file changes to a simple yet effective "azerty.jpg".
As you mentioned, the solution is probably in the browser's access rights. I just conducted tests by placing the HTML and the image in the "downloads" and "images/camera" folders, and I also checked that permission for file access and camera access was granted to the browser. Unfortunately, it still doesn't work :/
I'll look for a micro SD card in the bottom of my drawers; the access might be different on external storage.. -
I also tested it on various Android phones, under different versions. What surprises me is that it gets stuck with all those tested.
How is the HTML file launched: by clicking on it or by indicating its path in an application? What is it anyway: a browser, which one? A viewer?
Maybe it's related to the permissions granted to the application in question!? -
To launch the HTML file, I click on it via a file explorer application. Then the phone asks which application to use to open the file. I’ve done all my "tests" with Chrome, Opera, or the HTML viewer integrated into Android. Regardless of the application, the result is the same.
The applications in question can read the HTML file since the placeholder text is displayed. The links to other HTML files do not work either, but the problem is probably the same.
Regarding permissions:
- In the app settings: A list of permissions is displayed, and nothing seems to pertain to the phone's files (cookies, location, microphone...). The only options available are: "ask for permission" or "deny". Should I then request permission in the HTML code to be able to read files?
- In the phone settings: There are some permissions that can be granted or denied. For Opera, there is a permission related to storage, which I had checked at the beginning of my research. Regarding Chrome or the HTML viewer, they do not appear in these settings.
Thank you once again for your help! -
Yes, the photo album application does have access to the photo in question.
Thank you, in any case, for your patience and your help!
I hope that someone will have an answer :)
