파일의 내용을 가져 와서 base64를 사용하여 인코딩하는 스크립트가 있습니다. 이 스크립트는 정상적으로 작동합니다.PHP 디코드 base64 파일 내용
<?php
$targetPath="D:/timekeeping/logs/94-20160908.dat";
$data = base64_encode(file_get_contents($targetPath));
$file = fopen($targetPath, 'w');
fwrite($file, $data);
fclose($file);
echo "file contents has been encoded";
?>
이제 내용을 원래 값으로 다시 디코드하려고합니다. 나는 시도했다 :
<?php
$targetPath="D:/timekeeping/logs/94-20160908.dat";
$data = base64_decode(file_get_contents($targetPath));
$file = fopen($targetPath, 'w');
fwrite($file, $data);
fclose($file);
echo "file contents has been decoded";
?>
그러나 작동하지 않는다.
모두 같은 페이지에서 기록 될 수 있습니다. – Noman
작동하지 않는 이유는 무엇입니까? 예제 입력과 출력을 보여주고 실제로 얻은 것과 기대 한 것과의 차이점을 설명하십시오. –
아니요 동일한 스크립트에 있지 않습니다. – Joey