Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear Monks, im desperated ;-) im want to use the to upload a file via a webinterface, but the filehandle <$upload_Handle> give exactly nothing back.. :-(
if ($main::var{upload_file} ne "") { my @new_IP_data; if ($main::var{submit} eq "read") { my $loaded_IP_list; my $allowed_Types = "txt"; my $max_Size = 4096; my $filename = $q->param('upload_file'); $filename =~ s/.*[\/\\](.*)/$1/; $filename =~ s/\s/_/; my $upload = $q->param('upload_file'); my $file_Size = -s $upload; #$file_Size /= 1000; if ($file_Size > $max_Size) { print "<p>file is too big - only $max_Size all +owed - your file got $file_Size bytes</p>\n"; (my $kbsize,my $byt) = split(/\./, $file_Size) +; print "~ $kbsize KB"; exit; } (my $file_ID,my $type) = split(/\./, $filename); if($filename !~ /^\w+\.($allowed_Types)/) { print "only *.txt allowed"; exit; } $file_ID = time(); if (-e "$upload_Dir/$file_ID.$type") { print "Content-type: text/html\n\n"; print "file already exist"; } else { #### doesnt work $main::q::DISABLE_UPLOADS = 0; my $upload_Handle = $q->upload($filename); chdir($upload_Dir) or die "could not read target folder: $!"; if (!$upload_Handle && $q->cgi_error) { print $q->header(-status=>$q->cgi_error); exit 0; } my $error = $q->cgi_error; if ($error) { print $q->header(-status=>$error), $q->start_html('Problem'), $q->strong($error); exit 0; } while (<$upload_Handle>) { print; } print Dumper $q; print $upload; while(<$upload_Handle>){print $_;} print $upload_Dir; exit;
i still get no output. $q is initialised. dont know how to fix it. fyi: on an windows apache it works fine. but now i ported the script to a opensuse box. if i try to upload a file from my windows machine to the linux webserver where the script runs it give nothing back, even no errors.
$perlig =~ s/pec/cep/g if 'errors expected';

In reply to @CGI $q->upload() doesnt work properly by AlexTape

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (5)
    As of 2018-06-23 12:28 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (125 votes). Check out past polls.