Upload a audio file, have it play

Hello! Im trying to make a webpage thing where you can upload a mp3 file and have it play.

but it doesnt work. I have been trying to get it work for about 2 days now but i just cant figure it out. Does anyone see why this doesnt work? Its for html

Hi @BoiledFlea, can you try getting rid of the source tag and replace $("#src")... with $("#audio")...?

Hi @BoiledFlea
The problem seems to be that the add event listener line can’t run until the document is fully loaded. Since you have jquery, you can do this:


and put the

document.getElementById("upload").addEventListener("change", handleFiles, false);

line in that function!

Hope this helps :slight_smile:
If it did, press the ‘Solution’ button. Looks like @Pufferfish101007’s solution isn’t necessary. Correct me if I am wrong.


I think that is correct :slight_smile: I was even doing this earlier and I missed it :laughing:
Another option is to place the script tag right at the bottom of the page.

1 Like

That did the trick, thanks!