Вопрос

I am getting NULL form data values in %fdat variable in EmbPerl for file uploads with form property enctype="multipart/form-data".

Here is the EmbPerl code :

if(( defined $fdat{file} && $fdat{file} ) && $fdat{upload} )
{
         $filename = "/tmp/sample.txt";
         open (FILE, "> $filename") || die("open failed: $!");
         while (read($fdat{file}, $buffer, 32768)) 
         {
             print FILE $buffer || die("print test: $!");
             close FILE || die("close test: $!");  
         }
}

And HTML Code is :

<form name="form1" method="post" enctype="multipart/form-data" onsubmit="return validation();">
 <table>
  <tr>   
    <td>Select EXCEL sheet</td>
    <td><input type="file" name="file" value=""></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="upload" value="upload"></td>
   </tr>
 </table>
</form>

I am using EmbPerl/2.3.0, CGI/3.63, Perl/5.10.1, Apache/2.2.22 and Linux OS.

Это было полезно?

Решение

I got the solution.

It was the issue of CGI module version. Embperl uses CGI module internally to process forms encoded with multipart/form-data. you can retrieve the filename (local filename, as it was on the browser side) and the information provided by the CGI.pm uploadInfo function. The problem was fixed by upgrading CGI version to 3.37.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top