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

5411 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');

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by