paulnaj;10965293 wrote:if($break[1] == 'jpg') {
//DO THIS
}
if($break[1] == 'png') {
// DO THIS
}
if($break[1] == 'doc' || $break[1] == 'docx') {
// DO THIS
}
HI there, thank you for your response. i have changed yours a little and incorporated elseif instead of if so it only executes one condition... however i would like a condition whereby if it is none of these condiitons it will say 'file type invalid' or something like that. i tried an 'else' on the end but this didnt work.
my code:
<?php
$name = 'picture.doca';
$break = explode('.', $name);
echo $break[0], '.', $break[1];
echo '<br><br>';
if($break[1] == 'jpg') {
echo 'A JPG';
}
elseif ($break[1] == 'png') {
echo 'A PNG';
}
elseif ($break[1] == 'doc' || 'docx') {
echo 'A DOC OR DOCX';
}
else {
echo 'FILE NOT RECOGNISED';
}
?>
bradgrafelman;10965295 wrote:Also note that your logic above could easily be fooled, e.g. what happens if a file is named my_virus.jpg.exe?
Hello there, yeah its pretty basic, and im not sure how to fix that, however it will only be used within a local intranet for sharing excel documents etcetera and so security is not much of an issue
Regards
Josh