5 Replies - 860 Views - Last Post: 24 May 2013 - 06:11 AM Rate Topic: -----

#1 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

safe way to download binary then delete the binary from the server ?

Posted 23 May 2013 - 10:39 AM

hi guys, i am working on a file encrypter that encrypts binary files with passwords and i haev an upload form, and when the file is uploaded my backend C++ makes a new file and i need to download that file using php or any other language then delete the file afterwards safelly ;) please help me out here, i can't find a working way to do this because php finishes executing before the page loads :/ the problem with using header("Location: myfile.exe"); is because i have no way to call unlink afterwards :/ im really confused here

Is This A Good Question/Topic? 0
  • +

Replies To: safe way to download binary then delete the binary from the server ?

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2999
  • View blog
  • Posts: 10,384
  • Joined: 08-August 08

Re: safe way to download binary then delete the binary from the server ?

Posted 23 May 2013 - 11:44 AM

Without seeing your code I'm going to guess that system might be helpful.
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: safe way to download binary then delete the binary from the server ?

Posted 23 May 2013 - 01:15 PM

Uploaded files and files to download should be in a safe location. Not in the http server path.

Rather than offering up file.exe, give the user a php page the processes the request for a one shot download.
Was This Post Helpful? 0
  • +
  • -

#4 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

Re: safe way to download binary then delete the binary from the server ?

Posted 23 May 2013 - 01:23 PM

yea i have all the files in its own directory that i have restriced so they cannot access, but it is really hard to download a binary and delete it, its hard to explain but i just can't get it to work
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2999
  • View blog
  • Posts: 10,384
  • Joined: 08-August 08

Re: safe way to download binary then delete the binary from the server ?

Posted 23 May 2013 - 02:48 PM

So do you want us to wish you luck?
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: safe way to download binary then delete the binary from the server ?

Posted 24 May 2013 - 06:11 AM

I'm assuming, and I could be wrong, that the idea is to offer a single download of the file in question.

Reasonably, after that download, the file is no longer needed and you wish to remove it from your file system.

One solution is to simply tie it to the user's session. A session has a timeout and a session is open as long as there is activity. So, when the session ends, the file gets removed. There might be a trick tying the download activity to the session, though.

Alternately, you can handle the download yourself via PHP ( or whatever ). In this case, the server side script knows when it's done and removes the file after the last of the bytes are served up.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1