Page 1 of 1

Configuration of phpwebsite Documents module

Posted: Thu Feb 05, 2004 11:38 pm
by Giz
I came up against some problems getting the Documents module to handle some 1 megabyte files. Although these issues aren't all directly related to the module, I thought some people might find this information helpful.

In trying to upload a large file (1.5 mb) the behavior I was getting out of the box was that phpwebsite documents module would return a blank page. I guess more accurately, php was returning a blank page. The problem turned out to be in the /etc/httpd/conf.d/php.conf file. The RH9 rpm by default puts this section in that file:

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

The LimitRequestBody is setting the size of a request (including an upload) to 512k bytes. In order to support larger downloads, you either need to increase the number in the parameter, or delete the line from the file. This accounts for the module behavior when a larger file is specified in a form. Since I wanted to support uploads of from 2-2.5mb in size, I changed this to LimitRequestBody 2621440.

You also need to increase the value of the upload_max_filesize parameter in the php.ini file for uploads larger than 2mb.

You must always restart apache after any changes of this nature.

At that poing the uploads were working but I found that the upload (a .gz file) was being rejected. After looking at the code I found that this behavior was controlled in a source file.

mod/documents/conf/config.php

Numerous constants which controll behavior of the documents mod are defined here. The "file types" constant is this line:

define("JAS_DOCUMENT_TYPES", "application/octet-stream,application/msword,application/pdf,application/x-gunzip");

I simply added the Content-Type I needed so that I could get things working:

define("JAS_DOCUMENT_TYPES", "application/octet-stream,application/msword,application/pdf,application/x-gunzip,application/gzip");

In debugging this, I found it was helpful to have the module provide better information when it rejects a file. Knowing the content type allows an admin to go in and add it to the acceptable types list.

I made this change to line 101 of the Files.php class definition:

[php]
$this->messages[$i] = "<span style=\"color:#ff0000\">" . $_SESSION['translate']->it("The file uploaded was not an allowed file type: {$_FILES['JAS_Files']['type'][$i]}") . "</span>";
[/php]

If anyone intends to use the Documents mod to provide a download section to their site, they might need to accept all sorts of different Content-Types, so thought this might be helpful for other folks to know.[/php]

Hmmm.....

Posted: Tue Jul 13, 2004 7:31 am
by nobodyfamous
Uh... got a newbie question. Where exactly IS my PHP.INI file?
You also need to increase the value of the upload_max_filesize parameter in the php.ini file for uploads larger than 2mb.

You must always restart apache after any changes of this nature.
Im hosted with a webcompany and and used the FANTASTICO web installer for my website. I *THINK* that I may have to contact them to see if they'll change that file. Is this correct??

Steve

Posted: Tue Jul 13, 2004 1:25 pm
by Giz
Yes the php.ini file is a configuration file that sets things inside the php engine. If you have a virtual server account with fulll access to the root of the virtual server, you might be able to edit this yourself, but it's also possible that in a shared environment you don't have that ability.

The php.ini file on unix is typically in the /etc directory.

To further complicate things, any changes you make to php.ini require that the apache webserver be restarted for them to take effect.

So you may have to request your host to make any changes you require.