Hi,
Am Sonntag 08 August 2004 10:08 schrieb Alex Deva:
> Hey,
>
> I'm getting a weird problem. To reproduce it, I've set up a small template:
>
> <PKIT_COMPONENT NAME="/top">
>
> <PKIT_MESSAGE>
> <p>
>
> <form method="post" action="upload_done"
> enctype="application/x-www-form-urlencoded"> <input type="file"
> name="photo">
> <input type="hidden" name="pkit_done"
> value="http://<PKIT_HOSTNAME>"> <input type="image" img
> src="static/submit.png" width="67" height="20" border="0" name="submit"
> value="Submit"> </form>
>
>
> <PKIT_COMPONENT NAME="/bottom">
>
The main reason that this do not work is the enctype, try it with
enctype="multipart/form-data".
>
> In MyModel.pm, I have the following subroutine (just to check the number of
> uploaded files):
>
> sub upload_done {
> my $model = shift;
> my @filenames;
>
> foreach my $upload ( $model->apr->upload ) {
> my $fh = $upload->name;
> push @filenames, $fh;
> }
>
> my $pkit_done = $model->input('pkit_done');
> $model->pkit_gettext_message("file: ".$#filenames);
> $model->pkit_redirect("upload");
> }
>
your code looks fine for mod_perl 1, but with mod_perl 2 you should write
sub upload_done {
my $model = shift;
my $apr = $model->apr;
my @filenames = ();
foreach my $n ( $apr->upload ) {
my $name = $apr->upload($n)->name;
push @filenames, $name;
}
my $pkit_done = $model->input('pkit_done');
$model->pkit_gettext_message("file: ".@filenames);
$model->pkit_redirect("upload");
}
> The problem is the result is always -1 (and if I try to access any $upload
> object, it's undefined).
>
> Thank you for any help!
--
Boris
|