[Catalyst] file upload ( multipart/form-data) CGI trouble

k t sixperl at gmail.com
Mon Aug 28 10:15:44 CEST 2006

hello  ml members. I have a problem.
The application that up-loads the file is made.  This application is
executed CGI.
It is possible to up-load it in the catalyst test
server(testapp_server.pl) without trouble.
However, the reaction disappears after it up-loads it when executing
it with CGI(Apache2.0).
Post can be done without trouble, except when it is multipart/form-data.

After it waits for a while, the following error messages.

[Mon Aug 28 16:29:01 2006] [error] [client **] [error] Caught
exception in testapp::Controller::Root->upload "Wrong Content-Length
value: 20992 at /usr/local/lib/perl5/site_perl/5.8.8/Catalyst.pm line

please help me.
catalyst version 5.7001
<VirtualHost **** >
    ServerName test.cgiserver
    DocumentRoot /home/testcgi/public_html/
    ErrorLog /home/testcgi/error.log
    CustomLog /home/testcgi/access.log combined env=!no_log
    <Directory "/home/testcgi/public_html">
        AddDefaultCharset off
        Options IncludesNoExec ExecCGI
        Order allow,deny
        allow from ALL
        AllowOverride Limit AuthConfig Fileinfo Indexes
        <Files testapp_cgi.pl>
                SetHandler cgi-script
        Alias /testapp/ /home/testcgi/public_html/testapp/script/testapp_cgi.pl/


#!/usr/local/bin/perl -w


use strict;
use FindBin;
use lib "$FindBin::Bin/../lib";
use testapp;



catalyst testapp source

sub upload : Global {
  my ($self, $c) = @_;

  if ( my $upload = $c->request->upload('img1_file') ) {
    my $filename = $upload->filename;
    my $target   = "/home/testcgo/public_html/imgsrc/$filename";
    unless ( $upload->link_to($target) || $upload->copy_to($target) ) {
      die( "Failed to copy '$filename' to '$target': $!" );
  $c->stash->{template} = testapp->config->{template}->{test};

sub formtest : Global {
  my ($self, $c) = @_;
  $c->stash->{template} = 'formtest.tmpl';


  <meta http-equiv="content-type" content="text/html;charset=shift_jis">
  <title>Untitled Page</title>

 <body bgcolor="#ffffff">
  <form action="/testapp/upload" method="post" enctype="multipart/form-data">
   <input type="file" name="img1_file" size="10"><input type="hidden"
name="file" value="mode"><input type="submit" name="submitButtonName">

More information about the Catalyst mailing list