Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: file upload undefined: Operation now in progress

by kdj (Friar)
on Nov 25, 2008 at 20:23 UTC ( #725938=note: print w/replies, xml ) Need Help??

in reply to file upload undefined: Operation now in progress

According to the docs:  When called with the name of an upload field, upload() returns a filehandle, or undef if the parameter is not a valid filehandle.

I'm not able to test it at the moment, but I should think that your problem is that you are sending it the actual file name, and not the field that contains the file name.

my $filehandle = $q->upload('file'); should work.

Replies are listed 'Best First'.
Re^2: file upload undefined: Operation now in progress
by ksublondie (Friar) on Nov 25, 2008 at 20:44 UTC
    Sorry...forgot to mention that I tried that too and it doesn't work either. I found some example code that used that, so I decided to give it a whirl, but no luck. My original code snippet has transitioned while trying everything I can find.

    If I call $q->tmpFileName(), it's undefined as well. Is upload() supposed to be saving to /tmp? My permissions are drwxrwxrwt on /tmp. Is that what I need? I'm not able to find much detailed info in any doc.

    Error log says: readline() on unopened filehandle at /var/www/perl/modules/Lockbox/ line 1833.

      Even though, my other web app is still working, I found something that said some of the versions are screwed up & try v3.10 (was using the latest & greatest at v3.42). ...upload() is still undefined...

      What am I overlooking???

      ...still working on this...

      I've installed CGI::FileUpload to see where that gets me. Here's my current code:

      sub customerupload{ my $self = shift; my $q = $self->query; my @data; my $error = ""; my $filename = $q->param('uploadfile'); my $file; if($filename) { my $filehandle = new CGI::FileUpload(); $file = $filehandle->upload('query'=>$q); my $data; while(<$file>) { $data .= $_; } if($data) { $error = 'Successfull upload'; } else { $error .= $CGI::VERSION."Nothing read<br>$file +name<br>$file<br>"."<br>$!<br>"; } } else{$error .= $CGI::VERSION."file not uploaded <br>$filename< +br>$file<br>"."<br>$!<br>";} return $self->template({ file => 'customers.html', vars => {er +ror => $error, }}); }
      However, it crashes at the line in that uses the CGI::upload method (back to square 1):
      my $fhin=CGI::upload('uploadfile')||CORE::die "cannot convert [$filena +me] into filehandle: $!";
      The error message actually returns the name of my file i'm trying to upload. The CGI::FileUpload is creating the tmp files in /tmp/CGI-FileUpload dir: the key file (0 K), the key.part file (0 K), and the file (creates the file_orig, from_id, from_ipaddr, key, pid, and upload_status fields).

      don't know if I'm getting anywhere or not...


      I finally figured it out. I had an extra unclosed form tag in my HTML that was throwing it off.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://725938]
and the leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-06-24 00:14 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.