All answers are below your questions... Thank you for taking the time to parse through my code and try to understand what I am doing, I really appreciate it, this is the first time I have tried something like this and have been hung up on it for a couple days now... Scott
-----Original Message----- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Thursday, September 11, 2003 8:21 PM To: Raditha Dissanayake; Scott Dotson; [EMAIL PROTECTED] Subject: Re: [PHP] getting download resume to work Can you help explain this code? It looks like you're on the right track but have a few flaws (at first glance). > <?php > session_cache_limiter('public'); > session_start(); Is there a reason to be using sessions here? >>>>>>>ANS: not really as of yet, but, there will be as I will be restricting downloads to authenticated users... > set_time_limit(0); > $file=$_REQUEST['file']; > $extstart=strpos($file, "."); What does $extstart contain now? >>>>>>>ANS: just the first part of the name, before the extension, (for no reason) > $ext=substr($file, $extstart+1); So $ext is now a piece of the file. Why? >>>>>>>ANS: this is done so that I can set the ==header("Content-Type: application/".$ext);== > $dir="d:\\downloadable_courses"; > $size=filesize($dir."\\".$file); > header("Accept-Ranges: bytes"); So $size is now the size of the entire file (not the piece). >>>>>>>ANS: correct > if(isset($_ENV['HTTP_RANGE'])) { > list($a, $range)=explode("=",$_ENV['HTTP_RANGE']); So $a is now bytes, and $range is something like 123-456 >>>>>>>ANS: partly correct, what I receive is =="Range: bytes=14232-"== it has no last number. > str_replace($range, "-", $range); This makes no sense. The range requested is bytes 123 through 456, and you're converting this to 123456. Why? >>>>>>>ANS: when I left it on what it would send to the browser would be =="header("Content-Range: 123--456/457");"== (it would tack on an extra dash symbol (-) and the browser did not understand it) > $size2=$size-1; > header("Content-Range: $range$size2/$size"); > $new_length=$size2-$range; This will definitely not work, based on my comments above. >>>>>>>ANS: it appears to work enough that FlashGet will try to recover/resume and it completes, but, the byte count is always off by around 1 or so bytes and I cannot figure out why... If someone sends this header: Range: bytes=0-1023 and your resource is 2048 bytes in size, your response should include this header: Content-Range: bytes 0-1023/2048 Work on generating the correct string before you bother actually using them as headers and trying for the full solution. >>>>>>>ANS: I have set it to log to a text file previously and it is always 1 byte different. I am at a total loss as to where it is happening, I will attach the the log files that I have been pouring over as well the actual script to you... Hope that helps. Chris ===== Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
///////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\LOGGED FROM PHP AS HEADERS SENT\\\\\\\\\\\\\\\\\\\ ///////////////////////////////////////////////////////////////////// DOWNLOAD FILE -RESUME ONCE- FILE CORRUPT ****************FROM INITIAL**************** CONTENT-RANGE = 0-2510096/2510097 CONTENT-LENGTH = 2510097 ================FROM RESUME================= HTTP_RANGE = 1179140- CONTENT-RANGE = 1179140-2510096/2510097 CONTENT-LENGTH = 1330956 ///////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\FROM FLASHGET LOGS\\\\\\\\\\\\\\\\\\\\\\\\\\\ ///////////////////////////////////////////////////////////////////// ===================WHILE PAUSED======================= Fri Sep 12 07:46:30 2003 Connecting dotson.mine.nu:80 Fri Sep 12 07:46:30 2003 Connecting dotson.mine.nu [IP=65.243.148.6:80] Fri Sep 12 07:46:30 2003 Connected. Fri Sep 12 07:46:30 2003 GET /americas-best/download_test.php?file=getrt502.exe HTTP/1.1 Fri Sep 12 07:46:30 2003 Host: dotson.mine.nu Fri Sep 12 07:46:30 2003 Accept: */* Fri Sep 12 07:46:30 2003 Referer: http://dotson.mine.nu/americas-best/download_test_form.php Fri Sep 12 07:46:30 2003 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98) Fri Sep 12 07:46:30 2003 Pragma: no-cache Fri Sep 12 07:46:30 2003 Cache-Control: no-cache Fri Sep 12 07:46:30 2003 Connection: close Fri Sep 12 07:46:31 2003 HTTP/1.1 200 OK Fri Sep 12 07:46:31 2003 Server: Microsoft-IIS/5.0 Fri Sep 12 07:46:31 2003 Date: Fri, 12 Sep 2003 14:46:20 GMT Fri Sep 12 07:46:31 2003 X-Powered-By: ASP.NET Fri Sep 12 07:46:31 2003 Connection: close Fri Sep 12 07:46:31 2003 X-Powered-By: PHP/4.3.2 Fri Sep 12 07:46:31 2003 Set-Cookie: PHPSESSID=ca1ae38082e9cde9b945f5facc9e4d0e; path=/ Fri Sep 12 07:46:31 2003 Expires: Fri, 12 Sep 2003 17:46:20 GMT Fri Sep 12 07:46:31 2003 Cache-Control: public, max-age=10800 Fri Sep 12 07:46:31 2003 Last-Modified: Fri, 12 Sep 2003 14:37:36 GMT Fri Sep 12 07:46:31 2003 Accept-Ranges: bytes Fri Sep 12 07:46:31 2003 Content-Range: bytes 0-2510096/2510097 Fri Sep 12 07:46:31 2003 Content-Length: 2510096 Fri Sep 12 07:46:31 2003 Content-Type: application/exe Fri Sep 12 07:46:31 2003 Content-Disposition: inline; filename=getrt502.exe Fri Sep 12 07:46:31 2003 Start Receiving Data! Fri Sep 12 07:46:31 2003 Destination file exists, auto rename Fri Sep 12 07:46:33 2003 User Cancel At 1179140. ===================UPON COMPLETE====================== URL http://dotson.mine.nu/americas-best/download_test.php?file=getrt502.exe Comment getrt502.exe Referer http://dotson.mine.nu/americas-best/download_test_form.php Resume Yes Local File D:\Download\getrt502(1).exe File Date 09/12/03 14:37:36 File Size 2510096 Completed 2510096 Total Time 00:00:03 Average Speed 817.09 KB/s Create Time 09/12/03 07:46:29 Complete Time 09/12/03 07:46:52
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php