Ok I have a script to upload a file and I'm trying to name it by using the inputs from the form as the file name, but for some reason it just gives me a completely blank screen. The html file is at www.tdecsucks.com/upload.html and the cgi part is below. I've tryed all the obvious things, I've even tryed renaming the file after its saved as a temp file. I know the problem lies when I use a scalar as the filename, and yet I've seen it like this in two books. If anyone has had this problem or knows how I can go around this, I'd be in debt to you for life!

#!/usr/bin/perl -wT use strict; use CGI qw(:standard); print "Content-Type: text/html\n\n"; my $file = param ('uploadfile'); my $info = uploadInfo ($file); my $type = $info -> {'Content-Type'}; my $name = param ('name'); my $course = param ('course'); my $lastname = param ('lastname'); my $term = param ('term'); my $description = param ('description'); my $filename = "$name$course$lastname$term$description"; if ($file) { open (UPLOAD, ">/var/www/uploads/$filename") || Error (); my ($data, $length, $chunk); while ($chunk = read ($file, $data, 1024)) { print UPLOAD $data; $length += $chunk; if ($length > 5120000) { print "That file is too big. The limit is 5 Megs."; exit; } } close (UPLOAD); print "<p>You uploaded <b>$file</b> which had a MIME type of <b>$t +ype</b>."; print "<p>Your filename is <b>$filename</b>."; } else { print "No file was chosen."; } sub Error { print "Couldn't open temporary file: $!"; exit; }

In reply to Upload problem by Willman023

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.