145 posts
    Has been part of the Envato Community for over 2 years Located in Austria Has collected 1+ items on Envato Market Sells items exclusively on Envato Market
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

5324 posts The Dude Abides
    Located in United States Elite Author: Sold more than $75,000 on Envato Market Has sold $125,000+ on Envato Market Has been part of the Envato Community for over 5 years
+9 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
    Has been part of the Envato Community for over 2 years Located in Austria Has collected 1+ items on Envato Market Sells items exclusively on Envato Market
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