Re: File Upload Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wayne Donaho wrote:
> I am trying to run a file upload using PHP as a CGI script and am running
> into an odd error.
>
> The error I am getting is the dreaded Server Error -- Error 500 Premature
> end of script headers: php.cgi

Some more analysis ideas:

On the very first line of your script, print out something and call
http://php.net/flush and then "exit;".  Or is that what your "it ran"
script does?

Just want to be sure you have the "exit;" in there to be SURE it's a
server configuration error, and not something actually in your script to
kill PHP/CGI/Apache-child.

Check httpd.conf settings -- Perhaps you specifically disallowed certain
kinds of HTTP requests there... I have no idea *how* you can do this, or
if you can do this, but I hypothesize that it's possible to be done, so
maybe you did it.

I know you can disallow GET and/or POST etc, but not sure you can
fine-tune it down to mime-type or not.  It's up to you to figure out if
this can be done, and if you've done it in httpd.conf or not.  Possibly
also in .htaccess, also.

See if you can trigger the problem with *other* valid types of ENCTYPE --
The one used in the ubiquitous "PostToHost" function comes to mind.  If
you can determine that it's more than just multipart/form-data, and also
include, say, 'application/x-www-form-urlencoded' then it may help
identify the source or the problem.

For fun, take out the suexec on your development server and prove, once
and for all, that it's not related to suexec.

Since you've already tried so many other things, compile PHP without *ANY*
of the extra stuff.  No payfloPRO.  No GD. No zlib. No jpeg. No xpm. No
curl. No nothin' but --with-cgi (or whatever it is).  Just to eliminate
other software from the picture of possible culprits.

Are you doing any of this through SSL?  You don't really say, but you've
got SSL in the "./configure"...  Try it without SSL, of course, if you've
only tried with SSL so far.

Don't see how it could help, but error_reporting E_ALL is always a Good
Idea. :-)

> Here is the diagnosis I have done.
>
> 1.  The php.cgi executable deals with scripts correctly when using the GET
> method.
> 2.  The php.cgi script deals with POST method requests properly when the
>      enctype is NOT multipart/form-data
>
> This rules out suexec type errors.  (in any case the suexec log shows
> everything is good).
>
> 3.  File uploads using the mod_php work fine (this rules out apache not
> accepting the file)
>
> 4. the CGI log shows the request being sent to the script, and that there
> is
> no result.
>
> 5. The above error is not script dependent, the error occurs with a
> on-line
> script
>     that prints the string "it ran" when the form enctype is
> multipart/form-data.
>
> 6.  The upload script is being taken from a different box running
> different
> versions of apache/php
>      and the script works correctly there.
>
> I have tried this with various version of php all with the same results.
> I
> have built it with php.4.3.10.
>
> Here are the configure options from the phpinfo report:
> './configure' '--enable-force-cgi-redirect' '--with-openssl' '--with-curl'
> '--with-mysql' '--with-cgi'
> '--with-pfpro=/home/wayne/verisign/payflowpro/linuxrh9' '--with-gd'
> '--with-jpeg-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-freetype-dir'
> '--enable-ftp'
>
> I have the following file variables set:
> error_reporting 2039
> file_uploads On
> log_errors On
> max_input_time -1
> post_max_size 8M
> safe_mode off
> upload_max_filesize  2M
> upload_tmp_dir  /tmp


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux