Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by Anonymous Monk
on Mar 09, 2012 at 00:19 UTC ( [id://958566]=note: print w/replies, xml ) Need Help??


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

See this and follow the links deep, it discusses same problems your code has (in addition to what Eliya said)

The cgi documentation says $CGI::DISABLE_UPLOADS not $main::q::DISABLE_UPLOADS

See also Tutorials: Variable Scoping in Perl: the basics, Coping with Scoping , and start making subs/passing them arguments

  • Comment on Re: @CGI $q->upload() doesnt work properly

Replies are listed 'Best First'.
Re^2: @CGI $q->upload() doesnt work properly
by AlexTape (Monk) on Mar 09, 2012 at 11:39 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.
      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';

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://958566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-19 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found