File downloading Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ravikiran
Forum Newbie
Posts: 2
Joined: Tue Sep 16, 2008 1:45 am

File downloading Code

Post by ravikiran »

Hi Friends,

I am designing a website where some users upload documents specific to some other users with whom they are related.

To come over the issue of replacing old files (because of common file names) we are adding a suffix to every file uploaded and storing the original name in DB. When the user tries to download the file, we are recreating the file temporarily with the original name, allowing the download and then deleting that file.

When I try to download and click on the file - Pop-up blocker is stopping the file download. How can we by-pass this feature and download it?

In some websites I observed that a new window is opened and user is displayed with "Open", "Save" "Cancel" buttons and if the user clicks on Open/save, download starts immediately and the new window is closed automatically. I want to apply such functionality. Please guide me.

regards,
Ravi.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: File downloading Code

Post by Christopher »

Some of what you are describing is browser behavior and will be different in different browsers. You probably want to use a PHP script to do the download. Use the header() and readfile() functions.
(#10850)
Post Reply