http://qs321.pair.com?node_id=1232364

SearchigPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow monks,
I am running a script uploading files to my webspace as long as a certain filesize is not exceeded.

In case the file is larger, I want the script to prompt for a password in order to decide wether or not to abort the upload.
My Problem is that STDIN is not pointing to my keyboard but to the server's STDIN...

How to get around that Problem ? Hint: Term::Keys is not installed in the webserver
  • Comment on retrieving users input from the keyboard while perl is running in the remote webserver

Replies are listed 'Best First'.
Re: retrieving users input Form the keyboard while perl is running in the remote webserver
by marto (Cardinal) on Apr 09, 2019 at 20:04 UTC

    You don't say how you're dealing with the file upload, I more details a required in order to advise a solution.

      Hi there,
      thanks for your quick reply! This is THW code oft the upload-code:
      <br> use CGI; use CGI::Carp qw ( fatalsToBrowser ); use File::Basename; $CGI::DISABLE_UPLOADS=0; # Allow file uploads my $query = new CGI; my $filename = $query->param("datei"); my $kunde = $query->param("kunde"); my $upload_dir =$query->param("ziel"); my $groesse = $query->param("groesse"); my $action ="upload ".$filename; undef $fehler; $CGI::POST_MAX = 1024 * $groesse; $content_length = $ENV{'CONTENT_LENGTH'}; if ($content_length > $CGI::POST_MAX){ erlaubnis(); if ($sonder ne 'xxx'){ $fehler =" Datei groesser als erlaubt!"; goto Meldung; # custom request entity too large error handling } } }


      Hope that helps ?
      Cheers!

        So if you can stand JavaScript, and most people can, you could do something like this to get the file size before uploading. If your application can keep track of how much free space you have, a very basic example would be either querying this when rendering the upload page, or via a call back before you begin the file upload. As a side note your closing code tag should be </code>, rather than <code>.