Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load PDF... Delete File...

Status
Not open for further replies.
May 9, 2000
446
GB
Hi I'm storing some PDF files with eh file extension asp so that they can't be downloaded by a user guessing the code. Anyway I have a web page that renames the file with the pdf extension and gives it a new filename. The idea is that this file will then be viewed online by the user.

My problem is that although I've renamed the file so its pdf and has a new filename I don't know how to:

1. Get the new file to the browser so it can be viewed online

2. Ensure the new file with the PDF extension is deleted as soon as the browser has finished loading the file...

Any ideas anyone?
 
Hey FesterSXS cheers for the reply....

Yeah I realise they could then download it, thats fine by me! I just don't want people to be ablt to guess the path to the PDFs and download ones they shouldn't be allowed to saving the PDFs originally as asps' should stop that I guess.

Only thing I need now is something that will delete the tempoary new PDF file once the users browser has loaded it.... so i don't get millions of PDFs on me server!
 
When a PDF is loaded into a browser, I think it only loads the first page - subsequent pages then require another visit to the PDF on the server. If the PDF is deleted after the browser has loaded the first page then the rest of the PDF wont be available to the user.

Perhaps you could periodically delete the PDFs from the server?? Tony
 
Darn thats a shame I hadn't thought about it. Yeah I guess periodically deleting the PDFs may work, I guess I could put some script in the same page that looks for PDFs over a certain age and the actual web page deletes them? That might work I suppose, any thoughts on that?
 
Certainly one way of doing it - although if you are expecting high traffic then you would be better off doing it outside of the website. Every time someone tries to open a PDF through your site, the server would be checking for expired PDF files - this could get quite server intensive if it is doing it for multiple users at once.

Perhaps you could schedule a task in the OS to do it - not sure how though. Tony
 
Yeah see what you mean about server intensive.... I guess there wouldn't be that many users (these PDFs are going to be very boring!), scheduling through the OS would be one way but I doubt whether my admin. would set that up for me...

is there anyway to force a pdf to download in one big chunk so each page isn't downloaded individually d'ya know?
 
Instead of redirecting the browser to it, you could always embed the pdf in html. Something like this:

<EMBED src=&quot;example1.pdf&quot; width=&quot;450&quot; height=&quot;450&quot; href=&quot;example1.pdf&quot;></EMBED>

the Href is only for Netscape users. If you only have IE your supporting, then you can leave it out. Hope this helps!

EdCrosbys

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top