If upload file contains UTF-8 characters then CGI object creation fails when submitting the html form

StackOverflow https://stackoverflow.com/questions/23603095

  •  20-07-2023
  •  | 
  •  

Question

following is html filecontent:

<form name="myForm" action="/cgi-bin/bulkurls.cgi" enctype="multipart/form-data" 
          method="post" >


    <td align="right">Bulk Provisioning File
    </td>
    <td align="left"><input name="user_list" type="file">
    </td>
  </tr>
  <tr>
    <td align="center" colspan="2"><input class="ButtonNormal150" name="upload"  type="submit" 
        value="Process File">

CGI script is :

use CGI;
use strict;

my $query = new CGI;

at this moment CGI object creation is failed only file contain UTF chars. In case of plain text it's working fine. What is exact reason for this?

Était-ce utile?

La solution

You could try to setting utf8 like this. Also try to use a minimal valid HTML page for testing.

HTML:

<html>
<body>
<form 
name="myForm" 
action="/cgi-bin/bulkurls.cgi" 
enctype="multipart/form-data" 
method="post" >
<input name="user_list" type="file">
<input class="ButtonNormal150" name="upload"  type="submit" value="Process File">
</form>
</body>
</html>

bulkurls.cgi:

use strict;
use warnings;
use utf8;
use CGI qw(-utf8);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top