这是我在我的网站上上传文本文件的原始代码:
<?php
$myFile = $_GET['myFile'];
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $_GET['stringData'];
fwrite($fh, $stringData);
fclose($fh);
?>
它对你来说足够安全吗,还是我应该使用这样的东西:
<?php
if (isset($_GET['myFile'])) {
$myFile = basename($_GET['myFile']);
$fh = fopen($myFile, 'w') or die("can't open file");
}
$stringData = $_GET['stringData'];
fwrite($fh, $stringData);
fclose($fh);
?>