Saved Bookmarks
| 1. |
Solve : PHP Help.? |
|
Answer» HELLO, I am trying to create a PHP page to force the download of a file from another website. For instance a .swf file is located on a games website. When the person goes to my site and types in the url of the .swf file, instead of loading it in the web page I want my PHP script to send a header so that it forces a download. Without the file being located on my server. I know the basics but I need to know what HEADERS to send and how I can use them to force a download from another server. Thank you for any help. I will be checking back tomorrow, so don't wait up for a reply this evening.What software do you use on your site? If you are using one of the popular site builders written in PHP, you may find that its authors have a support area. They may already has code to do just about what you want.I write my own PHP, but when I force a download from another server the file is corrupted.What method are you using now? Can you post the code?Okay, something like this: Code: [Select]<?PHP // Define the path to file $file = 'ryboe_tag_cloud.zip'; if(!file) { // File doesn't exist, output error DIE('file not found'); } else { // Set headers header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-Type: application/zip"); header("Content-Transfer-Encoding: binary"); // READ the file from disk readfile($file); } ?> |
|