0

i do not know how to fix this message that appears on line with $newfilename = uniqid() ... :

$allowedExts = array("gif", "jpeg", "jpg", "png", "zip", "html", "htm",  "js", "css", "less", "txt", "php");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);

// skipped

echo // here the echo's

$newfilename = uniqid().".".end(explode(".",$_FILES["file"]["name"]));
  move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" .     $newfilename);
  // het pad naar het bestand dat geupload is; ervan uitgaande dat de map uploads in de root staat
  echo 'Url: ' . '<b>http://www.jouwwebsite.nl/uploads/' .    $newfilename.'</b>';
  echo '<br /><br />';
}
// skipped...
Frans
  • 11
  • 1
  • Split it into two lines: `$data = explode(".",$_FILES["file"]["name"]); $newfilename = uniqid().".".end($data);` – Mark Baker May 21 '15 at 21:39
  • But there is a better function for extracting the extension from a filename: [pathinfo()](http://www.php.net/manual/en/function.pathinfo.php) with the `PATHINFO_EXTENSION` flag: `$newfilename = uniqid().".".pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);` – Mark Baker May 21 '15 at 21:40
  • Or in this case perhaps: [How to get the file extension in PHP?](http://stackoverflow.com/q/10368217) (Still may not be advisable to use as unfiltered source for a target filename extension.) – mario May 21 '15 at 21:40
  • Thanks for the solution. Message is gone! – Frans May 21 '15 at 21:45

0 Answers0