Upload to and remove from the server dir

Upload file to the server directory:

$upload_dir = './some_files/';

$file_name = $this->generate_random_string(); // see generate_random_string() function

$file = $_FILES['some-file']['tmp_name'];

move_uploaded_file($file, $upload_dir . $file_name);

Remove file from the server directory:

unlink( $upload_dir . $file_name );