Redirect to a pdf file and then delete on the server
Posted: Tue Dec 16, 2008 5:46 pm
Hello, I have a php script that builds a .fdf file and stores it in a folder. No trouble there. Then I was using a header/location redirect to open that file (the .fdf file is linked to a pdf so it opens the pdf filled out). No trouble here either. The issues is there is sensative information in the fdf file so as soon as the user opens it I want it deleted off the server. Basically the user will open this file and print it but in the background I want it deleted from the server. I tried to unlink the file after my redirect but it always unlinks first so then my redirect points to something that doesn't exist. I tried putting a sleep function in but it just delays the unlink and then redirects. I need the redirect to happen first but continue to run the script on the page so it unlinks without the user having to do anything. Here is a snippit:
header ("Location: https://www.mysite.com/formdata/$fdf_file");
unlink("formdata/$fdf_file");
Please help. And if there is a different way I am all ears. Thanks.
header ("Location: https://www.mysite.com/formdata/$fdf_file");
unlink("formdata/$fdf_file");
Please help. And if there is a different way I am all ears. Thanks.