【发布时间】:2014-05-09 19:26:11
【问题描述】:
我有一个 PHP 脚本,它加载 175KB 文件的内容,但在页面顶部失败。 (它应该适用于较小的文件!!) 这是脚本 sn-p:
if(!file_exists($sFile) || !is_readable($sFile)) {
echo "<span style='color: #FF3333;'>Can not find/open file.</span><br />";
} else {
if(isset($_GET['content']) && is_writable($sFile)) {
$hFile = fopen($sFile, "w");
fwrite($hFile, urldecode($_GET['content']));
fclose($hFile);
}
$sContent = file_get_contents($sFile);
}
?>
<a href="<?php echo "?page=browser&path=" . dirname(realpath($sFile)); ?>" title="Back to <?php echo dirname(realpath($sFile)); ?>">
» Back to <i><?php echo dirname(realpath($sFile)); ?></i>
</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
<input type="hidden" name="page" value="edit" />
<input type="hidden" name="file" value="<?php echo $sFile; ?>" />
<textarea name="content" placeholder="..." style="margin: 0; padding: 0; width: 100%; height: 350px; resize: vertical;"><?php echo $sContent; ?></textarea>
<input type="submit" value="Save changes" style="width: 100%;" />
</form>
【问题讨论】:
-
你可以在这里找到答案:stackoverflow.com/questions/162176/… 它引用了 fopen 的超时。我相信这也是你的问题。
标签: php fopen file-get-contents