homepage Welcome to WebmasterWorld Guest from 54.204.127.56
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
headers, octet-streams, & handling multiple requests
quixotic




msg:3324974
 7:15 pm on Apr 28, 2007 (gmt 0)

I have a page with several links to different 'user' files (which are located outside the webserver). Clicking on the link executes a php file that does some user validation and returns the 'user' file via a header:

<?PHP ...

//force download dialog
header("Content-type: application/octet-stream\n");
header("Content-disposition: attachment;
filename=\"$file\"\n");
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
exit();

?>

The issue is, while they wait for one file to download they can't request another file until the script finishes streaming the first file. Is there a way around this?

I thought maybe using "Content-Type: multipart" might work. Anybody have and idea how I would do this?

 

quixotic




msg:3328077
 12:54 am on May 2, 2007 (gmt 0)

Got it! It's the session PHP is worried about. Solution? write close the session.

After writing all your session variables (if any), add the following:
session_write_close();

... and yahtzee! it's working. Man, I love an easy fix.

eelixduppy




msg:3328078
 12:57 am on May 2, 2007 (gmt 0)

Glad to see it, quixotic!

I was just looking into your question to see what I could come up with :) Thanks for sharing your solution.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved