145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

Hello, Got a problem.

I’ve coded a meta box with a media upload button. But I want audio files to be uploaded.

For Images I got the URL of the uploaded images url like so:

formfield = $(this).prev().attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');

...

fileurl = $('img',html).attr('src');

But if I upload an audio file, fileurl is set to “undefined”, of course. Do you know what to change to get the url of the audio file in the variable fileurl?

Thank you

5311 posts The Dude Abides
  • United States
  • Exclusive Author
  • Has been a member for 5-6 years
  • Elite Author
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
  • Author had a Free File of the Month
+5 more
CodingJack says

Not sure how your form works, but this is how you would get the file url of an upload:

$("input[type=file]").change(fileSelected);

function fileSelected() {

    console.log(this.value);

}

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

ok, thank you. might work, but it’s a little bit too different from my coding.

the solution for me was to change “image” to “audio” in the tb_show. And change the last line to

fileurl = $(html).attr('href');
by
by
by
by
by
by