Yet Another Upload Question: I've been surfing this site and google hoping to find a simple solution for uploading files (of any size or type) to a web server. I wrote some code that creates the appropriate file on the remote server, but when I FTP to my server to check on the file it is 0kb in size. What am I doing wrong? Also, what type of checking should I use to assure the file is uploaded correctly? Thanks.
#!/usr/bin/perl -w use strict; use CGI; my $dir = '../billimages/'; &performUpload($dir); sub performUpload { my ($dir) = @_; my $cgi = new CGI; my $file = $cgi->param("file"); my $i; open (LOCAL, ">$dir$file") or dieNicely("Unable to upload: $!"); while (read($file, $i, 1024)) { print OUT $i; } close (LOCAL); dieNicely("Upload Complete"); } sub dieNicely { print "Content-type: text/html\n\n"; print "$_[0]"; }
edited by boo_radley - title change (was : YAUQ)

In reply to problems uploading to an HTTP site by emilford

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.