Hi all,
In a secured php document I have a file uploader that was only for PDFs but they want xlsx, xls, ,docx, txt, rtf and ppt file extensions.
To filter the files coming in I have this:
$allowedExtensions = array("txt","csv","htm","html","xml",
"css","doc","xls","rtf","ppt","pdf","xlsx","docx");
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
if (!in_array(end(explode(".",
strtolower($file['name']))),
$allowedExtensions)) {
die($file['name'].' is an invalid file type!');
}
}
}
Once the check is done i am ready for upload. The only thing is how do I get the name of the file that is being uploaded and store it as the filename to be displayed for download purposes. This is what I have now:
$result = move_uploaded_file($_FILES['files']['tmp_name'],
FILEREPOSITORY."/$file");
if ($result == 1) echo "<p>File successfully uploaded.</p>";
else echo "<p>There was a problem uploading the file.</p>";
Thanks for any help on this in advance.