bogeyman Posted December 12, 2008 Share Posted December 12, 2008 Dear all, I try to make a PHP script for resumable download, so I try to search it on search engine. I got it and I modified the code a little bit. The code is like this <?php $file = "D:\\Software\\Oracle Instant Client\\instantclient-basic-win32-10.1.0.4-20050513.zip"; $fileName = "InstantClient.zip"; $filesize = filesize($file); $offset = 0; $length = $filesize; if ( isset($_SERVER['HTTP_RANGE']) ) { $partialContent = true; preg_match('/bytes=(\d+)-(\d+)', $_SERVER['HTTP_RANGE'], $matches); $offset = intval($matches[1]); $length = intval($matches[2]) - $offset; } else { $partialContent = false; } $file = fopen($file, 'r'); fseek($file, $offset); $data = fread($file, $length); fclose($file); if ( $partialContent ) { header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize); } header('Content-Type: ' . $ctype); header('Content-Length: ' . $filesize); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Accept-Ranges: bytes'); print($data); ?> I try run the script with Firefox, then I pause the download process. Then the problem start. I got an error message like this. InstantClient.zip.part could not be saved, because the source file could not be read. Try it again later, or contact the server administrator. I can't resume my download. I just can start it from the begining. Can anyone tell me what's wrong? Thanks before. Link to comment https://forums.phpfreaks.com/topic/136643-resumable-download/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.