function onSendFileClick($event) { $fileDialog = new wxFileDialog($this, "Select a file"); if ($fileDialog->ShowModal() != wxID_CANCEL) { $current_selection = $this->m_usersList->GetSelection(); $name = $this->m_usersList->GetItemText($current_selection); foreach ($this->m_users as $client_position => $username) { if ($name == $username) { $message = "send_file," . $fileDialog->GetFilename(); socket_write($this->m_user_sockets[$client_position], $message, strlen($message)); $this->files_to_send[$client_position] = $fileDialog->GetPath(); break; } } } }