0

When I use vscode to add audio and pictures to an HTML file, I use "open with live server" to debug, but every time the pictures and audio are not loaded. However, when I quit vscode and open it directly with a browser, it can load the pictures and audio normally. I don't know what the reason is, is there a problem with the vscode?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer" />
    <title>Document</title>
</head>
<body>
   
    <img src="F:\LABORATORY\HMpy\images\me1.png">
    <audio src="F:\BaiduNetdiskDownload\women.mp3" controls ></audio>
    
</body>
</html>
Phoenix
  • 37
  • 5

1 Answers1

0

Please put your audio and image next to your html file and use relative path. like so:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer" />
    <title>Document</title>
</head>
<body>
   
    <img src=".\me1.png">
    <audio src=".\women.mp3" controls ></audio>
    
</body>
</html>
Alireza
  • 2,319
  • 2
  • 23
  • 35
  • I corrected the fault according to the method you said. Thank you very much for your help! – Phoenix Jul 11 '20 at 11:54
  • Sorry, if it's convenient, I would like to ask, why would it be wrong to use the absolute path, but it can work normally with the relative path? – Phoenix Jul 11 '20 at 12:32
  • no problem at all. please take look at https://stackoverflow.com/questions/21728850/how-to-give-src-to-the-img-tag-in-html-from-the-system-drive – Alireza Jul 11 '20 at 12:40