logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache doubles file size during php upload script?
Author
Klaipedaville



Joined: 12 Oct 2013
Posts: 22

PostPosted: Mon 10 Mar '14 19:33    Post subject: Apache doubles file size during php upload script? Reply with quote

Hello there,

I have a very strange problem which is apache related I assume. I have a pretty simple PHP file upload script. It uploads files to my Linux server without any issues as I have all possible and impossible PHP errors' logging turned on. It reports no errors and files upload well. The only problem is the files double in size during the upload process. For example if the original file is 10Kb before the upload then it becomes 20Kb after the upload. Then if I want to try to view the file via apache (any web browsers) or download it back it says the file is corrupt and it is impossible to open it. I tested the script extensively and it worked OK on 3 different servers but does not seem to work on mine... There are no errors in any logs reported anywhere at all... The only problem I accidentally found manually myself was this mysterious double in file size during the upload... I am getting completely lost and would appreciate any help / suggestions at all. Many thanks in advance!

I tried adding / removing these of course as per known old bugs but no joy:

<Files *.php>
AddInputFilter PHP .php
AddOutputFilter PHP .php
</Files>

<Files *.php*>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

AddType application/x-httpd-php .php4 .php3 .phtml .php

AddType application/x-httpd-php .php .phtml .phtm .inc .oc
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 11 Mar '14 18:46    Post subject: Reply with quote

I would use just one single line

Code:

AddHandler application/x-httpd-php .php .php4 .php3 .phtml .phtm .inc .oc
Back to top
Klaipedaville



Joined: 12 Oct 2013
Posts: 22

PostPosted: Tue 11 Mar '14 19:37    Post subject: Reply with quote

Hello James,

Many thanks! I would definitely give it a try and let you know the results.

I tried the lines I mentioned earlier separately and all together and in custom configuration files as well as regular configuration files... but nothing helped.
Back to top
Klaipedaville



Joined: 12 Oct 2013
Posts: 22

PostPosted: Tue 11 Mar '14 20:01    Post subject: Reply with quote

James Blond wrote:
I would use just one single line

Code:

AddHandler application/x-httpd-php .php .php4 .php3 .phtml .phtm .inc .oc


Here is my feedback. It does not work either but I appreciate any tips and hints at all. Thank you.

Although could you please, clarify where do I add those? Perhaps I am using the wrong location or something.

Plus, here is what I additionally found about this issue. It's on php.net but in fact it is also apache related isn't it? https://bugs.php.net/bug.php?id=19263
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 11 Mar '14 23:49    Post subject: Reply with quote

It has been a while since I used apache as a module on linux so you might have to adjust the paths and or the file name of the module to your installation / distro

That is in httpd.conf or some distros apache2.conf
Code:

#
LoadModule php5_module "/usr/bin/local/php/php5apache2.so"
AddHandler application/x-httpd-php .php .php4 .php3 .phtml .phtm .inc .oc

# configure the path to php.ini
PHPIniDir "/etc//php5"
Back to top
Klaipedaville



Joined: 12 Oct 2013
Posts: 22

PostPosted: Wed 12 Mar '14 6:59    Post subject: Reply with quote

Many thanks for following up on this, James!

I am on it, reading about using apache as a module on Linux. Although I am not quite sure what it is used for in this configuration. Doesn't it come like this right out of the box?

The most unusual part here is that it had worked OK for quite some time before I installed the latest updates. You know this regular updates you receive time to time (not the upgrades). Could these updates mess it up like this?

Anyway, I am really grateful for your help and will double check on modules and paths.
Back to top
Klaipedaville



Joined: 12 Oct 2013
Posts: 22

PostPosted: Wed 12 Mar '14 15:56    Post subject: Reply with quote

Here is my update. I would like to post it as it may also help someone else with the same problem.

I discovered that php5_module or php5 or libphp5.so (which happens to be the same thing) was missing at all. I had only libphpfilter.so instead for some reasons.

I first tried at the command line the following: a2enmod php5 and it said that there weren't such files or directories in ../path/php5.load

Then I searched for a package that contained the missing stuff by entering the following command:

apt-file search php2.load

It replied that the package that contains php2.load file is called libapache2-mod-php5 which in turn happens to be my missing php5_module or just php5 or libphp5.so (the same things).

Now I have simply run the command:

apt-get install libapache2-mod-php5

It also installed all the other missing dependencies for php5.

The steps above solved the double in size problem without even adding any AddHandlers anywhere. This issue was purely PHP related and it was solved back in 2004 as it was only apache version 2.0.4 and php version 4.3.1 related. Anything above that should work fine without adding any extra Handlers or Types.

Final note. I am not sure what might have caused it but the fact remains on hand. The php5 module was missing for some reason and it was the culprit for all the trouble.

My special thank you goes to James Blond who brought the "LoadModule php5_module" up! Very Happy and suggested to look into it Wink
Back to top


Reply to topic   Topic: Apache doubles file size during php upload script? View previous topic :: View next topic
Post new topic   Forum Index -> Apache