2014-10-29 4 views
0

urlencode에 약간의 문제가 있습니다. 폴더의 파일에 ±, ę, ć, ś 등과 같은 폴란드 문자가 있지만 링크를 클릭하면 작동하지 않습니다. 내가 뭘 잘못하고있어? 폴란드어 문자가 작동하지 않는 urlencode

php > $a = array(); 
php > echo urlencode($a); 
PHP Warning: urlencode() expects parameter 1 to be string, array given in php shell code on line 1 

당신은 아마 대신 urlencode($fileinfo)을 원하는

foreach ($dir as $fileinfo) { 
      ^---array 
    $doc='<div class="dopobrania"><a href="'.$path.urlencode($dir).'" 
                   ^----array 

예 : : : 당신은 당신의 배열에는 urlencoding하고

<?php 
       function rozszerzenie($plik){ 
       preg_match("/\.([^\.]+)$/", $plik, $matches); 
       if(count($matches) > 0) { 
        return $matches[1]; 
        } 
       return false; 
       } 
       $path = "pliki/"; 
       $dir = new DirectoryIterator($path); 
       foreach ($dir as $fileinfo) { 
        $rozsz = rozszerzenie($fileinfo); 
        $doc='<div class="dopobrania"><a href="'.$path.urlencode($dir).'" target=_blank>'.$fileinfo.'</a></div>'; 
        $pdf='<div class="dopobrania_pdf"><a href="'.$path.urlencode($dir).'" target=_blank>'.$fileinfo.'</a></div>'; 
        $zip='<div class="dopobrania_zip"><a href="'.$path.urlencode($dir).'" target=_blank>'.$fileinfo.'</a></div>'; 
        $inny='<div class="dopobrania_inny"><a href="'.$path.urlencode($dir).'" target=_blank>'.$fileinfo.'</a></div>'; 
        if($rozsz == "doc"){ 
         echo $doc; 
        } 
        elseif($rozsz == "pdf"){ 
         echo $pdf; 
        } 
        elseif($rozsz == "zip"){ 
         echo $zip; 
        } 
        else { 
         echo $inny; 
        }; 
       } 
       ?> 

답변

0

: 이것은 내 코드입니다.

관련 문제