0

Hopefully this is a pretty simple question for those who know javascript but I couldn't figure it out. Basically I have a save file dialog box created with this:

<div>
<input type="file" id="file" onchange="loadFile(this)">
</div>

It is linked to the "loadfile" function shown below:

function loadFile(input) {
  var file = input.files[0]
  var url = file.urn || file.name;

  ID3.loadTags(url, function() {showTags(url);}, {tags: ["title","artist","album","picture"],dataReader: FileAPIReader(file)});
}

I am trying to replace the line

 var file = input.files[0]

to be a file from a string (specified path) instead of relying on the file browser dialog. I have tried something like this:

 var file = files("song.mp3")

but the resulting function will not work. I am guessing that my variable file isn't of the right type. How do I get it to be the same type as the selected file from the file dialog box?

Thanks in advance!

PS: I am trying to link my script to a path on the server not the client.

1 Answer 1

1

If you want to access data from a website, then use the XMLHttpRequest object instead of the Files API.

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry for the confusion but I am trying to link my script to a file on the server not the client. I know this will most likely need to be done with some php but am unsure how to.
So var file = XMLHttpRequest("song.mp3") ?
Err… no, but there are many guides to XMLHttpRequest so I'm not going to write another one here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.