[PHP-users 8611] Re: multipart/form-data & encoding conversion

Yasuo Ohgaki php-users@php.gr.jp
Fri, 12 Jul 2002 10:55:29 +0900


Âç³À¤Ç¤¹¡£

Taro Yamamoto wrote:
> form ¥¿¥°¤Ë multipart/form-data ¤¬Æþ¤Ã¤Æ¤¤¤ë¤È¡¢
> POST ¥Ç¡¼¥¿¤Îʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤òÊÑ´¹¤·¤Ê¤¤¤½¤¦¤Ç¤¹¤¬¡¢

ÊÑ´¹¤·¤Þ¤»¤ó¡£¤³¤ì¤Ï¤É¤Î¥¤¥ó¥×¥Ã¥È¤òÊÑ´¹¤·¤Æ¤â¤è¤¤¤«¥·¥¹¥Æ¥à
¤Ç¼«Æ°Åª¤ËȽÃǤǤ­¤Ê¤¤¤«¤é¤Ç¤¹¡£

# ¼«Æ°¤Ç¤Ïfile A¤ÏÊÑ´¹¤¹¤ë¤¬¡¢file B¤Ï¤·¤Ê¤¤
# ¤Ê¤É¤È¸À¤¦»ö¤ÏÉÔ²Ä
# ¤Þ¤¿¡¢ÌÀ¼¨Åª¤Ë¼«Æ°ÊÑ´¹¤ò¥ª¥Õ¤Ë¤·¤¿¤¤¾ì¹ç¤â¤¢¤ë
# ¤Î¤Çmultipart/form-data¤Ç¤ÏÊÑ´¹¤·¤Ê¤¤»ÅÍÍ
# ¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤Î»ÅÍͤÏ¿ʬÊѤï¤é¤Ê¤¤¤È»×¤¤
# ¤Þ¤¹¡£

¼«Æ°¤Ç¤Ç¤­¤Ê¤¤»ö¤Ï¼«Ê¬¤Ç¥×¥í¥°¥é¥à¤ò¹Í¤¨¤ì¤Ð¤è¤¤»ö¤Ê¤Î¤Ç
´Êñ¤Êʪ¤Ï¤¢¤Þ¤ê¿Í¤Ëʹ¤¯Êª¤Ç¤Ï¤Ê¤¤¤È»×¤¤¤Þ¤¹¤¬¡¢¡¢¡¢

Î㤨¤Ð

$fld_to_conv = array('data1','data2');
foreach( $fld_to_conv as $fld) {
  $_POST[$fld] = mb_convert_encoding($_POST[$fld], 'EUC-JP');
}

¤È¤¹¤ë¤È¡¢ÆÃÄê¤Î¥Ç¡¼¥¿¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤òÊÑ´¹¤Ç¤­¤Þ¤¹¡£
¥Õ¥¡¥¤¥ë¤À¤±ÊÑ´¹¤ò¹Ô¤Ê¤¤¤¿¤¯¤Ê¤¤¾ì¹ç¤Ï¤â¤Ã¤È´Êñ¤Çmb_convert_variable¤ò
»È¤¦¤È°ìȯ¤Ç¤¹¡£

¥Þ¥Ë¥å¥¢¥ë¤È¸«¤ÆÎϻŻö¤Ç

$_POST['data1'] = mb_convert_encoding($_POST['data1'], 'EUC-JP');
$_POST['data2'] = mb_convert_encoding($_POST['data2'], 'EUC-JP');

¤Ç¤â½½Ê¬¤Ê»ö¤â¿¤¤¤È»×¤¤¤Þ¤¹¡£

´Ø¿ô¤Î»È¤¤Êý¤¬¤ï¤«¤é¤Ê¤¤¡¢¤É¤ì¤ò»È¤Ã¤ÆÎɤ¤¤«¤ï¤«¤é¤Ê¤¤Åù¤Î
¾ì¹ç¤Ï¼«Ê¬¤Ç¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È¤òºî¤ë»ö¤ò¤ª¾©¤á¤·¤Þ¤¹¡£

--
Yasuo Ohgaki