Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: file upload undefined: Operation now in progress

by kdj (Pilgrim)
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.


Comment on Re: file upload undefined: Operation now in progress
Select or Download Code
Re^2: file upload undefined: Operation now in progress
by ksublondie (Pilgrim) 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/User.pm 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 CGI::FileUpload.pm 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 key.properties 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...

      OMG!!!

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2015-07-07 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls