How to extract a filename from a URL to save locally

cahoots 7 years ago updated by icahill (Administrator) 7 years ago 1
I'm using the download tag to save an arbitrary selection of sound files locally so that they can be played while offline.Can anyone suggest how I can extract just the filename from the URL in order to use that as a variable for the filename?
Your best bet here is to just javascript to extract what you need. Check out this example below: 

         <text name="Test" alias="TEST" width="100%" height="100" color="#ffffff" font="Arial" size="16" align="center" alignment="center" text=""></text>
    <action name="on" oninit="yes">
        <assign property="var:url" value="http://rarewire.com/file.jpg" />  
        <assign property="object:TEST.text" value="[eval: '[var:url]'.replace(/^.*(\\|\/|\:)/, '')]" />