Loading ...
Sorry, an error occurred while loading the content.

uploader help

Expand Messages
  • gabriel_1k
    I am trying to creat an image uploader, but Im having trouble with it. Can anyone show me how to get just the file name and ext.? Here is the code I have now:
    Message 1 of 1 , May 3, 2006
    • 0 Attachment
      I am trying to creat an image uploader, but Im having trouble with
      it.
      Can anyone show me how to get just the file name and ext.?

      Here is the code I have now:

      #!/local/bin/perl -w
      use strict;
      use CGI ':standard';

      print "Content-type: text/html\n\n";

      my $file = param ('uploadfile');
      my $info = uploadInfo ($file);
      my $type = $info -> {'Content-Type'};

      if ($file) {
      open (UPLOAD, ">../uploads/") || Error ();

      my ($data, $length, $chunk);
      while ($chunk = read ($file, $data, 1024)) {
      print UPLOAD $data;
      $length += $chunk;
      if ($length > 51200) {
      print "That file is too big. The limit is
      50K.";
      exit;
      }
      }
      close (UPLOAD);

      print "<p>You uploaded <b>$file</b> which had a MIME type of
      <b>$type</b>.";

      } else {
      print "No file was chosen.";
      }

      sub Error {
      print "Couldn't open temporary file: $!";
      exit;
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.