optikalefx Posted February 2, 2009 Share Posted February 2, 2009 HI all, I have a file placed outside my web directory. I create via php a sym link to that file so a user can download that file. After the download, or after a period of time, i need the sym link to be removed and i need to add some info to my database that the download is done. any ideas? Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 2, 2009 Share Posted February 2, 2009 Instead of symlinking the file, you might want to create a download script that takes in an id and looks up the filename in a database. Then you can send the correct headers and call readfile() to force the download. This way, you can flag the download in the database so you know it has been downloaded. You can also use a cron job to clean up downloads that have been sitting around for too long. Quote Link to comment Share on other sites More sharing options...
optikalefx Posted February 2, 2009 Author Share Posted February 2, 2009 Is there any way to tell that the download is completed? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 2, 2009 Share Posted February 2, 2009 Is there any way to tell that the download is completed? Don't believe so - at least not directly. There might be a way to check through the server logs/data to see if it "sent" all the packets for the file. But that is still no guarantee that they all made it to the client. Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 2, 2009 Share Posted February 2, 2009 Is there any way to tell that the download is completed? Nope, much better to just put a time limit on it. Quote Link to comment Share on other sites More sharing options...
optikalefx Posted February 2, 2009 Author Share Posted February 2, 2009 How can you put a time limit on it? I thought of cookies but thats not always good, and sweeping the server folder but that requires constant checks. The issue is that on this last download page, no more PHP is run, unless i do something via ajax when they click the download link. But i cant kill the sym link when they click the link of course. The download script idea was alright, except it doesnt work for this because this download link is an XPI for a firefox extension and if the link is not to a .xpi then the javascript wont verify it even if i redirect the headers and all. So im thinking itll have to be attached to the download? or if there exists a self destructing timer? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted February 3, 2009 Share Posted February 3, 2009 Just when someone goes to the page check if the download time is over and if it is remove it from the db or whatever you want, that or run a cron job. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.