note 54838 added to function.session-write-close

From: Date: Sun, 17 Jul 2005 03:05:43 +0000
Subject: note 54838 added to function.session-write-close
Groups: php.notes 
Request: Send a blank email to php-notes+get-92066@lists.php.net to get a copy of this message
session_write_close() worked as a lifesaver for me when automatically uploading files to a user (forcing a download instead of a link). If files are large, and since session_start() does not allow another page using session_start() to proceed until it's done, i was not able to upload more than one file at a time. By using session_write_close() before beginning the file upload, my users can now download as many big files as they like, at the same time. Example: <? session_start(); /* Do session stuff here; security; logging; etc. */ session_write_close(); /* NOW write out the requested file. */ header("Content-type: audio/x-mpeg"); /* or whatever type */ header("Content-Disposition: attachment; filename=" . $filename); header("Content-Length: " . $filesize); header("Content-Transfer-Encoding: binary\n\n"); header("Pragma: no-cache"); header("Expires: 0"); $file_contents = file_get_contents($filepath); print($file_contents); ?> ---- Manual Page -- http://www.php.net/manual/en/function.session-write-close.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54838 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54838&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54838&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92066) next »