Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

File upload quit working

by Anonymous Monk
on Jan 19, 2012 at 09:03 UTC ( #948719=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I had this working perfectly, now all of a sudden, it is not. I have not changed the main code, yet the output variable is always blank now...

can you tell me if this is wrong?

my $filename = param("incoming"); my $handle = upload("incoming"); $filename =~ s/(?:\\|\/)([^\\\/]+)$/$1/g; my $buffer; my $_tFileContains = ""; while (read($handle,$buffer,2048)) { $_tFileContains .= $buffer }
That was populating the file contains variable every time. Now, $_tFileContains is blank, always. Yet the filename is there, so I know it is getting the file, I have tried a lot of different files, even ones that worked in the past. Nothing.

any idea why it would not work now?

Is there a better way to do it? I guess I could write it to a temporary file then just read the file to get the data and then parse it, then delete the file when I am done, but there must be a way to get this working.

I am not sure if maybe there was an update to perl that made it happen or what...

I would appreciate any help you can be.

Thanks,
Richard

Comment on File upload quit working
Select or Download Code
Re: File upload quit working
by Anonymous Monk on Jan 19, 2012 at 09:06 UTC
    BTW, this is a system to upload and scan .csv files to get returned email addresses out of a file from bounced emails to our club members...
Re: File upload quit working
by Anonymous Monk on Jan 19, 2012 at 10:22 UTC

    can you tell me if this is wrong?

    It doesn't look particularly wrong, but it is only a fragment

    Yet the filename is there, so I know it is getting the file

    Maybe you do, maybe you don't, what does cgi_error() show? what does the server log say?

    What does DebugCGI show?

Re: File upload quit working
by Anonymous Monk on Jan 19, 2012 at 12:23 UTC
    I fixed it. I guess, even though I am using CGI, I needed to define a new cgi:
    my $q = new CGI; my $filename = $q->param("incoming"); my $handle = $q->upload("incoming");
    That did it.

    So I fixed it myself. Thank you for taking the time to offer a suggestion. There were no errors at all.

    Richard

      So I fixed it myself. Thank you for taking the time to offer a suggestion. There were no errors at all.

      CGI offers two interface, oo interface  CGI->new ... and functional interface  use CGI qw/ param upload /; ...

      If you're trying to use the functional interface, but you fail to import param/upload, your program would have died with

      $ perl -MCGI -e " param() " Undefined subroutine &main::param called at -e line 1.

      So yes, there was definitely a problem

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-11-29 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls