473,573 Members | 3,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP scripting problem

I have a VERY frustrating script problem I hope some one can help me with.
I am using part of the following PHP download script to allow users to
download files from my website:

<?php
$file = '/download/whiteskullvalle y.exe';
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($filen ame));
header('Content-Disposition: attachment; filename=' . basename($file) );
readfile($file) ;
?>

Everything works fine as long as the file size is relatively small (say
around 5 MB) but if I try and use it to download a large file (say around 50
MB) I get Error 500 "Internal Server Error" and when I check my error log I
get:

Premature end of script headers: /web/cgi-bin/php4

I have also tried a few different download scripts and they all give me the
same error.

Any help with this would be greatly appreciated
Jul 17 '05 #1
2 1692
skadmin wrote:
<?php
$file = '/download/whiteskullvalle y.exe';
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($filen ame));
header('Content-Disposition: attachment; filename=' . basename($file) );
readfile($file) ;
?>

Everything works fine as long as the file size is relatively small (say
around 5 MB) but if I try and use it to download a large file (say around
50 MB) I get Error 500 "Internal Server Error" and when I check my error
log I get:


http://www.php.net/manual/en/function.flush.php
http://www.php.net/manual/en/functio...time-limit.php

C.
Jul 17 '05 #2
In article <ksvwd.585224$D %.458796@attbi_ s51>,
"skadmin" <So*******@Nowh ere.com> wrote:
I have a VERY frustrating script problem I hope some one can help me with.
I am using part of the following PHP download script to allow users to
download files from my website:

<?php
$file = '/download/whiteskullvalle y.exe';
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($filen ame));
header('Content-Disposition: attachment; filename=' . basename($file) );
readfile($file) ;
?>

Everything works fine as long as the file size is relatively small (say
around 5 MB) but if I try and use it to download a large file (say around 50
MB) I get Error 500 "Internal Server Error" and when I check my error log I
get:

Premature end of script headers: /web/cgi-bin/php4

I have also tried a few different download scripts and they all give me the
same error.

Any help with this would be greatly appreciated


I do the following with my code:

$h = fopen($file, "rb");
$content_len = (int) filesize($file) ;
$content_file = fread($h, $content_len);
fclose($h);

@ob_end_clean() ;
@ini_set('zlib. output_compress ion', 'Off');
header("Pragma: no-cache");
header("Cache-control: private");

header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: none');
if (ereg("IE",$_SE RVER[HTTP_USER_AGENT]))
header('Content-Type: application/octetstream; name="' . $file . '"');
else
header('Content-Type: application/octet-stream; name="' . $file . '"');

header('Content-Disposition: attachment; filename="' . $file . '"');
header("Content-length: $content_len");
echo $content_file;
exit;

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
2707
by: Quest Master | last post by:
I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting language was available. However, I want to code this application in Python, and I have not yet heard of an implementation of another scripting language...
2
2807
by: Fedroz | last post by:
Hi! Here is my problem: I'm trying a simple script copied by MSDN for read a text file and put the content on output web page! I use the following code: Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject")
8
5573
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and stuffing quite a lot of data (from and MS SQL database) into them. On Windows 2000 server, everything is fine. If the data structures get really...
9
2272
by: Vijai Kalyan | last post by:
Hello All, I have a few questions which you might seem irrelavant and/or foolish. I am asking anyway so I can find out. 1. Is XSL as powerful as a programming language such as Java in its abilities to transform XML? The W3C site has the following definition on XSLT for example: "XSLT is designed for use as part of XSL, which is a...
2
2141
by: dito | last post by:
I have a .asp page that contains an activex componet. When I launch it in a browser, it returns an error that the viewer is unable to create it's resource objects. "To rectify this problem, please install IE4.0 or install DCOM for W95 and the latest MS Scripting Engine. These files are available at MS's website" I am running IE6.0. Where...
1
4101
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters. The below explanation is lengthy, but well worth the read. If you can help me, I'd gladly share this code which has greatly helped my...
4
1715
by: Dimitris | last post by:
Hello, I have a problem that it seems easy but its really not. I am using Microsoft remote scripting for a site that I am making. Everything is going pretty good except one thing. My values which I want to store in the database(this procedure takes place in the calling page) are being stored with wrong and wuth no sence characters. So far I...
9
1778
by: Code4u | last post by:
I have an application that manipulates large arrays of image data of various types, all the usual arithmetic operations on the data objects are supported. With careful design and tricks similar to those in UBLAS (http://www.boost.org/libs/numeric/ublas/doc/) I have been able to avoid temporaries where appropriate and carefully optimize code...
7
3901
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
8
4171
by: Nagarajan | last post by:
Hi group, I need to develop a web application. I am in a fix as to choose among the various server-side scripting options. I want to explore python (am a newbie) to gain expertise and upon search, I learnt about PSP(Python Server Pages) that uses Jython as its scripting language. Is it a better option over PHP or Perl? Could anyone point out...
0
7778
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7777
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6413
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3731
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1300
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1039
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.