我有一个脚本获取文件的内容并使用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