SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there...see if anyone can help me out

    I just got a CGI script from the net which enables me to upload files from my hard drive to the server which is hosting my site.
    The problem is this. I uploaded the cgi script onto the server, and a simple html file with a form which allows you to browse for a file, and then upload it.
    When you hit the uplaod button, the cgi script is called.
    Problem is that when the cgi script is called, i get this error message:

    ERROR!
    Can't locate CGI.pm in @INC at /afs/.ac.psiweb.com/home/18/ac002013/admin/upload.pl5 line 5. BEGIN failed--compilation aborted at /afs/.ac.psiweb.com/home/18/ac002013/admin/upload.pl5 line 5.

    I know what the CGI.pm is, but why cant it find it? according to my server providers, they say that they have the latest perl installed, and that the path from my cgi script to their perl directory is correct..so whats going on?
    At the bottom of this message i have pasted the cgi script that i am using, please help if you can!
    Thanks
    Alex
    #!/usr/local/bin/perl

    use strict;
    use CGI qw/:standard/;

    my $tmpdir = "IMAGES/"; # place to store files - change me if youlike
    my $use_rename = 1; # set to use rename instead of file copy
    sub print_error;

    # output content header

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

    # get filename args

    my $cgi = new CGI or die "new CGI: $!\n";
    my @filename = $cgi->param('filename'); # must match form name
    &print_error ("Missing filename arg\n") if @filename < 1;

    # start HTML

    print <<EOD;
    <HTML>
    <BODY>
    <CENTER>
    <H1>Results of file upload</H1>

    EOD

    # do for each file to upload

    foreach (@filename) {

    # skip empty slots

    next if length $_ < 1;

    # extract just the filename

    (my $file = $_) =~ s/^.*?([^\\\/]+)$/$1/;
    my $tmppath = "$tmpdir/$file";

    # if try renaming temp file

    if ($use_rename) {

    # close CGI.pm temp file

    close $_ or print "Error closing tempfile '$_': $!\n";

    # check file has some size or print error

    my $tmp = $cgi->tmpFileName($_);
    my $size = -s $tmp;
    if ($size < 1) {

    print "<P><B>Zero length file '$_' not uploaded: $!\n";
    print "<BR>Check file spec in upload form</B></P>\n";
    next;
    }

    # rename CGI.pm temp file to upload dir

    rename $tmp, $tmppath or
    print "Error renaming '$tmp' to '$tmppath': $!\n";

    # check file size on disk

    my $loc_size = -s $tmppath;

    print "<P><B>File '$_' uploaded to '$tmppath', " .
    "local size=$loc_size</B></P>\n";
    next;
    }

    # else we'll copy the temp file

    # open output file

    open OUT, ">$tmppath" or &print_error ("Error opening $tmppath: $!\n");
    binmode OUT;

    # copy file

    my $buffer = '';
    my $size = 0;
    while (my $line = read $_, $buffer, 4096) {

    print OUT $buffer;
    $size += $line;
    }
    close OUT;

    # check file size on disk

    my $loc_size = -s $tmppath;

    print "<P><B>File '$_' uploaded to '$tmppath', size=$size, " .
    "local size=$loc_size</B></P>\n";

    # close CGI.pm temp file

    close $_ or print "Error closing tempfile '$_': $!\n";

    # delete CGI.pm temp file

    my $tmp = $cgi->tmpFileName($_);
    unlink $tmp or print "Error deleting tempfile '$tmp': $!\n";
    }

    print <<EOD;
    </CENTER>
    </BODY>
    </HTML>
    EOD

    exit 0;

    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    sub print_error {

    print <<EOD;
    <HTML>
    <BODY>
    <CENTER><H1>$_[0]</H1></CENTER>
    </BODY>
    </HTML>
    EOD

    exit 0;

    }

    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  2. #2
    SitePoint Zealot
    Join Date
    May 2000
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why don't you just copy CGI.pm to the directory where you have the upload.pl file?

    I think it should work then.

    You should be able to download it from http://search.cpan.org/

    Arpith

  3. #3
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying,

    Yes i have tried that already, and when it started to compile, it got a little further, but then stopped because CGI.pm refers to some other objects.
    I got these objects, and tried again. But now its asking for another object (content.pm) which should be in the perl/lib directory of my server providers.

    I am pretty sure that i have the right perl path at the beginning of my program, but it seems like it aint looking for it there or something.
    What to do? - does anyone know of anyother simplier ways of using xgi to upload??

    Alex
    Thanks
    P.s. i know you can use ASP, but my server providers dont like it for some reason!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •