3 Replies Latest reply on Apr 30, 2007 3:15 PM by insuractive

    CFfile - make new directory copy, and force download then go to new URL

      Hello ,
      I am coding an MP3 download that basically makes a new folder then goes to the stored location and copies the mp3 and places it in a new folder that later can be deleted. Once the folder is made and the mp3 is in it - the idea then is to force the download by sending it to a force download script in an iframe ( php script )
      Then re-locate the enduser to an alternate page.

      Sounds easy?

      The problem - Is that the forceddownload works if the mp3 is already there, so I am guesing that the code runs too fast and when it gets to the force download script - the mp3 file has not yet been written. yet If this is so - how can I make sure that it is there first and then have it wait until the code is run before it executes the forcedownload and redirect?

      Below is the script I am using - the problem is that each bit of coding works seperately but when run together it goes straight to the <cflocation> and skips the download bit.
      <cfset newFold = replace(getCurrentTemplatePath(),getFileFromPath(getCurrentTemplatePath()),'')>


      <cfset newPath= #REReplace(#getSong.SongFileLoc1#,"/","\","ALL")#>
      <cfset mp3Path= #REReplace(#getSong.NewFileLoc1#,"/","\","ALL")#>

      <cfset newDir="#newFold##newPath#">
      <cfset MusicDir="#newFold##mp3Path##getTuneVerified.TuneKeyCode#">


      <p><cfoutput><cfset rootPath = replace(GetDirectoryFromPath(" http://"&cgi.server_name& cgi.path_info),"\","")></cfoutput></p>

      <!--- <p><cfoutput>#newDir#</cfoutput></p> --->
      <cfset downloadMe = "#rootPath##getSong.NewFileLoc1##getTuneVerified.TuneKeyCode#/#getSong.SongFileName1#">

      <cfif DirectoryExists(musicDir)>
      <cfquery name="theHits" datasource="theTunes2">
      UPDATE Tunecard
      SET Downloaded = Downloaded + 1
      WHERE Tunecard.TuneID = #getTuneVerified.TuneID#
      </cfquery>
      <iframe width=0% height=0% scrolling="no" frameborder="0" src='<cfoutput>forceDownload.php?file=#getSong.NewFileLoc1##getTuneVerified.TuneKeyCode#/ #getSong.SongFileName1#</cfoutput>'></iframe>


      <cflocation addtoken="no" url="#GetArtistInfo.ArtistLandingPage#">