Friday 13 May 2005 8:34:04 pm
Hey Guys, *wheew*, what a day! I feel a little guilty. That I didn't post on this topic more quickly. <i>I'll make it up ... ! -- dade murphy</i> <b>The Problem</b> The problem is that there are at least Three (3) different configuration dependencies for LAMP (Linux, Apache, MySQL, PHP) web applications like eZ publish required to support large file uploads. Unfortunately, when I say large file uploads, this is a bit of a misnomer, because by default (Apache / PHP) supports file uploads of only less than 1.5 MB (closer to 1.30 MB). Additionally eZ publish includes support for life upload size restriction settings. <b>The Solution</b> <b>PHP</b> First you want to check your web server's 'php.ini' configuration file to ensure your application server's settings (php) allow for the desired upload limit. <i>As a rule of thumb</i>, I always add 10MB additional to the specified desired file size limit for additional padding in case of the occasionally larger file than planned. This reduced unplanned maintenance and surprises later. I think it's worth it if your already having to change the settings in the first place. Here is an example of the settings <b>I</b> would use. These are tested production settings from my last project. ;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = 25M
<b>Apache</b> Next you need the ability / freedom to have these entries added into to either your httpd.conf or .htaccess file. <i>Warning these are different styles of the required settings for each method.</i>
<i>httpd.conf method</i> This can goes inside the your httpd.conf before your virtual host definitions, inside your virtual host definitions. I recommend adding this code on a per virtual host basis to maintain a most secure configuration for the entire server (less is more). Alternately I believe, if you use apache2, you may place this code in a new file located at <i>'/etc/httpd/conf.d/httpd_limit_upload.conf'</i> <Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 37000000
# (max size in bytes)
</Files>
<i>.htaccess method</i> If you don't have access to your 'httpd.conf', don't loose hope! You can alternately place this code into your .htaccess file. SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 5242888
<b>Performance Tip</b> The Apache web server performs <i>significantly</i> if not <b>drasticly</b> faster when you do not use a .htaccess file (actualy) when apache it is not set to use/look for .htaccess files at all, I personally recommend .htaccess files for initial development hosting and relocation of the rules in the .htaccess file into your httpd.conf virtual host definitions for production web sites. It's just a very very good idea to take advantage of the performances advantages possible by placing your mod_rewrite rules and other apache configuration directives inside your httpd.conf Note: <i>Be sure to restart apache inorder for the these configuration settings changes to be loaded</i> Most cutting edge / enlightened hosting firms these days respect the client's absolute need for full control over the entire application server / settings hosting their their production eZ publish applications. If you don't have root / full access to your server, your paying too much for too little. There are several eZ publish Hosting Partners from which you can acquire this level of service at very reasonable rates for Virtual Dedicated Servers and (Completely) Dedicated Servers. http://www.ez.no/partner/partner_list/(partner)/hosting/(sort)/name
<b>eZ publish : File Upload Form</b> This step is <i>optional</i> in most situations (and more as a general reference) because eZ publish supports a 30.5 MB limit by default in most templates which provide upload forms. The html form which you upload your file from also can the hidden form field <b>MAX_FILE_SIZE</b> (placed into the default templates in eZ publish (admin)) Here is an example of a static file upload form. The <b>MAX_FILE_SIZE</b> cannot be larger than upload_max_filesize in php.ini (default 2MB, real limit is really less than 2MB, actual usable 1.4MB or less ). The <b>MAX_FILE_SIZE</b> represents maximum file size accepted in bytes (not KB or MB), for files uploaded using this form with this setting. <form enctype="multipart/form-data" action="/modulename/action" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="32000000" />
Choose a file to upload: <input name="userfile" type="file" />
<input type="submit" value="Upload File" /></form>
This hidden field must precede the file input fields (order) in the HTML. This field is only advisory to the browser and is easy to circumvent and not secure to rely on it for a secure hard limit. The cool thing about this FAQ, is that it covers just about all versions of eZ publish (and most web applications).
cheers, //kracker
<i>bubba sparxxx : lovely korn : end of days : camel song</i>
<b>References</b>
<i>http://www.netspade.com/articles/php/uploading.xml
http://httpd.apache.org/docs/howto/htaccess.html http://httpd.apache.org/docs-2.0/misc/perf-tuning.html
bytes to megabytes calculor (from google.com)
http://www.google.com/search?num=50&hl=en&lr=&safe=off&c2coff=1&q=37000000+bytes+to+megabytes&btnG=Search </i>
Member since: 2001.07.13 || http://ezpedia.se7enx.com/
|