Here's a snippet of a file upload subroutine I wrote that works pretty nice. I don't know of any particular reason that it wouldn't work on Win2k, though I haven't done perl programming on it. Make sure your directory is writable by this script.

It runs under strict. The original does automatic duplicate checking and stores file attachment names in an mySQL database (this is part of a larger document management web app). I stripped out the mySQL parts 'cuz they didn't seem important.

Good luck. If you know how to use subroutines this should be easy. If not, you should be able to figure it out anyway.

You invoke it by passing it the param of the file form element, followed by the desired filename param.
Example:
if($q->param("attach1")){uploadfiles('attach1',$q->param('attach1filename');}

##### Uploads files sub uploadfiles{ my ($param,$filename)=@_; my $filepath="/www/ejc/docs/"; my ($i); my $file = $q->param($param); $filename=~ s/([^\w.-])/_/g; $filename=~ s/^[-.]*//; if ($filename =~/^([-\@\w.]+)$/){ # untaint filename $filename= $1; } open(OUT,">$filepath"."$filename") or die("Can't open outfile for +writing: $!"); while (read($file,$i,1024)) { print OUT $i; } close(OUT); } ##### End of file upload.

Update: Changed regex, per ryanus's suggestion below.


In reply to Re: Need upload Help for win 2000 by Hero Zzyzzx
in thread Need upload Help for win 2000 by Falazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.