<?php
function upload_file($file, $path) {
    if ($file->isValid() && !$file->hasMoved()) {
        $newName = $file->getRandomName();
        $file->move(FCPATH . $path, $newName);
        return $newName;
    }
    return false;
}