2013-07-01 30 views
0
if(!empty($_FILES['csv'])){ 
     $this->autoRender = false; 
     $text = file_get_contents($_FILES['csv']['tmp_name']); 
     header('Content-type: application/CSV'); 
     header('Content-Disposition: attachment;filename=' . $_FILES['csv']['name']); 
     echo $text; 
     return; 
} 

我没有问题,上传文件,然后再出来,你可以在上面看到随地吐痰回来......但我需要特殊字符转换像重音字符和EM - 进入等效或HTML版本。我该怎么做?PHP:上传CSV和转换特殊字符为HTML

Windows 7中的Apache 2.2.21,PHP 5.4.3,CakePHP的1.3

+0

最终使用此(有点脏)功能发现在http://alanwhipple.com/2011/06/04/php-clean-encoding-issues-smart-curly-quotes-em-dashs/ – azBrian

回答

1

看看功能htmlentities()

据我所知,你可能只是你的echo输出变为

echo htmlentities($text); 

不要忘了看看可用的标志in the manual,它允许一些微调取决于你想要什么。

+0

没有帮助, htmlentities不会转换emdash或重音字符... – azBrian

0

您可以使用PHP的htmlentities功能:

$text = htmlentities(file_get_contents($_FILES['csv']['tmp_name'])); 

为了扭转这一点,如果你在任何时候需要,使用html_entity_decode

+0

没有帮助,htmlentities不会转换emdash或重音字符... – azBrian