0

How to extract a filename from a URL to save locally

cahoots hace 11 años actualizado por icahill (Administrator) hace 11 años 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: 

<wire>
    <main>
         <text name="Test" alias="TEST" width="100%" height="100" color="#ffffff" font="Arial" size="16" align="center" alignment="center" text=""></text>
     
    </main>
    <actions>
    <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(/^.*(\\|\/|\:)/, '')]" />
    </action>
    </actions>    
</wire>