• Welcome to Valhalla Legends Archive.
 

[Perl] File uploads

Started by Undeference, August 31, 2004, 03:28 PM

Previous topic - Next topic

Undeference

Okay, it's official: I can't find how to handle file uploads. I used to be able to do this, mind you, but it is only more recently that I've forgotten.
I can't even find any information on files being passed to CGIs. I know how the file is sent, I just don't know what the server does with it.

Any help please?

Banana fanna fo fanna

#1
are you using a library or doing it yourself?

EDIT: google found me this: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=348&lngWId=6

Undeference

#2
Okay... at any rate... here's how you can go about doing this (FYI, I was being stupid...):

enctype="multipart/form-data"



  • my ($postdata) = '';
    while (read (STDIN, $postdata, 1, length ($postdata)) != 0) { print $!; }

    or

  • my ($postdata) = '';
    while (!eof (STDIN)) { read (STDIN, $postdata, 1, length ($postdata)); }

    or

  • sub post {
      my ($res, $result) = (' ', '');
      while ($res ne '') { $result .= &readdata; }
    }
    sub readdata {
      read (STDIN, $r, 1) or die "Couldn't read standard input: $!";
      return $r;
    }

    or

  • my (@lines) = <STDIN>;