uploading files

Discussion in 'Perl Misc' started by D Borland, Oct 13, 2003.

  1. D Borland

    D Borland Guest

    Hi again folks,

    I'm trying to get the script below to work. I've checked it's syntax and
    perl says that it's ok, i cannot check the logs on the server as 1&1
    webhosting don't seem to allow me that, as when i run the script i get a
    server 500 error, with no info on why :( I've checked to see if the script
    still managed to upload the file which it did... any ideas?

    Thanks for your time.

    __CODE__

    #!/usr/bin/perl

    use strict;
    use warnings;

    use CGI;
    use CGI::Carp 'fatalsToBrowser';

    $CGI::pOST_MAX = 1024 * 500;

    my $query = new CGI;

    my $filename = $query->param('image1');
    my $fileToUpload = $query->upload('image1');
    my $uploadDir = "$ENV{'DOCUMENT_ROOT'}/beta";

    $filename =~ s/.*[\/\\](.*)/$1/;

    open(NEWFILE, ">$uploadDir/$filename")
    or die "Cannot create new file $uploadDir/$filename : $!\n";

    binmode(NEWFILE);

    while (<$fileToUpload>) {
    print NEWFILE;
    }

    close(NEWFILE);

    print $query->p("File uploaded");

    __END__
     
    D Borland, Oct 13, 2003
    #1
    1. Advertising

  2. D Borland

    D Borland Guest

    ooops! :)

    Forgot to print the header first, guess i was just looking at it too long,
    and just didn't see it until i sat back for a bit.
     
    D Borland, Oct 13, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raymond chiu

    Uploading files to Windows Server

    raymond chiu, Jan 6, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    517
    =?Utf-8?B?Tm90SGVscGZ1bA==?=
    Jan 12, 2006
  2. PJ

    Re: Uploading large files

    PJ, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,120
  3. Dung Ping
    Replies:
    10
    Views:
    1,057
    Chaddy2222
    Jan 16, 2006
  4. dermoon
    Replies:
    0
    Views:
    514
    dermoon
    Oct 8, 2003
  5. Andrew Chan

    Problems: uploading files have Chinese named files

    Andrew Chan, Apr 16, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    201
    Andrew Chan
    Apr 16, 2004
Loading...

Share This Page