$isFile=instant_remote_process(["test -f $path && echo OK || echo NOK"],$server);
$isDir=instant_remote_process(["test -d $path && echo OK || echo NOK"],$server);
if($isFile=='OK'&&$fileVolume->is_directory){
thrownew\Exception("File $path is a file on the server, but you are trying to mark it as a directory. Please delete the file on the server or mark it as directory.");
thrownew\Exception("File $path is a directory on the server, but you are trying to mark it as a file. Please delete the directory on the server or mark it as directory.");