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

Re^2: @CGI $q->upload() doesnt work properly

by AlexTape (Monk)
on Mar 09, 2012 at 11:39 UTC ( #958688=note: print w/ replies, xml ) Need Help??


in reply to Re: @CGI $q->upload() doesnt work properly
in thread @CGI $q->upload() doesnt work properly

hm ok..

but thats not new to me.. the code i show you is only part of an package. the cgi object lies in the main. for that itīs not a scoping issue.
  my $filename = $q->param('upload_file');
gives exactly the filename of the uploaded file. but not full qualified.
here you are right:
$CGI::DISABLE_UPLOADS
$main::q is initialised in the main with
our $q = new cgi;
but the attribute should set like

use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX=1024 * 100; # max 100K posts $CGI::DISABLE_UPLOADS = 1; # no uploads
thanks for the pointer.
like Eliya said:
my $filename = $q->param('upload_file'); # returns (client-side) +name of the file my $filehandle = $q->upload('upload_file'); # returns handle to the +server-side temp file
thats still my code. but the filehandle is empty. thats what i want to fix. i want to know what this function do:$q->upload('upload_file'); because it might be that there is a problem with fetching the data from the client..?!
sorry 4 my worse diction..
$perlig =~ s/pec/cep/g if 'errors expected';


Comment on Re^2: @CGI $q->upload() doesnt work properly
Select or Download Code
Re^3: @CGI $q->upload() doesnt work properly
by Anonymous Monk on Mar 09, 2012 at 12:55 UTC

    hm ok.. but thats not new to me.. the code i show you is only part of an package. the cgi object lies in the main. for that itīs not a scoping issue.

    :) Um, if you know this is bad way to code (multiple exit points, action at a distance, not maintainable), why continue to use globals like that and call exit?

    my $filename = $q->param('upload_file'); gives exactly the filename of the uploaded file. but not full qualified.

    Except that it only gives what the browser sends, and the browser can send anything, including a full path full of dots, or anything at all. You're trusting the browser/user to not be evil. Don't trust, code so as to protect yourself. Full path for uploaded file, Security issues when allowing file upload via CGI, use taint and launder dirty data

    but the filehandle is empty. thats what i want to fix.

    Do you have the latest version of CGI? You should. Then, if filehandle is still empty, there must be something in cgi_error or in server logs

    i want to know what this function do

    Well, see both CGI documentation and sourcecode and you'll know :) its undef on error

      :) Um, if you know this is bad way to code (multiple exit points, action at a distance, not maintainable), why continue to use globals like that and call exit?
      :) your completly right.. iīm desperated in finding any error message. for that the code is full of any exits to test what happen in that part of the script. the pm is more then 1600 lines.. donīt want to go further with an empty file ^^

      the cgi_error is still empty. should check the server logs... mh tmpFileName() looks intresting ;-)

      thanks for advice!
      $perlig =~ s/pec/cep/g if 'errors expected';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://958688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-10-21 04:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (96 votes), past polls