This is my original code to upload text files in my website:
<?php
$myFile = $_GET['myFile'];
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $_GET['stringData'];
fwrite($fh, $stringData);
fclose($fh);
?>
Is it secure enough for you or should I use something like this:
<?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);
?>