diff --git a/headers/client.h b/headers/client.h
index 05907229fb2d995d4ac36f73b7223480a821f421..d8a15faf5c74d94de43d818dbb7746975bc09e9f 100644
--- a/headers/client.h
+++ b/headers/client.h
@@ -230,9 +230,9 @@ vector<char> client::read_file(string fileName) {
 void client::send_file() {
   string fileName;
   do {
-    cout << "Digite o nome do arquivo(maximo de " << TAM_DADOS << " char):\n";
+    cout << "Digite o nome do arquivo(maximo de " << TAM_DADOS - 4 << " char):\n";
     getline(cin, fileName);
-  } while (fileName.size() > TAM_DADOS);
+  } while (fileName.size() > TAM_DADOS - 4);
 
   // Envia o primeiro frame com o tamanho do arquivo
   string fileSize = calc_file_size(fileName);
@@ -246,13 +246,17 @@ void client::send_file() {
   }
 
   // Envia o segundo frame com o nome do arquivo
-  //  cout << "Enviando nome do arquivo\n";
-  //  if (!send_message(vector<char>(fileName.begin(), fileName.end()), MIDIA))
-  //  {
-  //    cout << "Limite de timout, arquivo nao foi enviado\n";
-  //    return;
-  //  }
-  //
+  cout << "Enviando nome do arquivo\n";
+  string name = "NAME";
+  vector<char>fileNameVector(name.begin(), name.end());
+  fileNameVector.insert(fileNameVector.end(), fileName.begin(), fileName.end());
+
+  if (!send_message(fileNameVector, MIDIA))
+  {
+    cout << "Limite de timout, arquivo nao foi enviado\n";
+    return;
+  }
+  
   //  cout << "Enviando arquivo\n";
   //  vector<char> file = read_file(fileName);
   //  if (file.empty() || !send_message(file, DADOS))
diff --git a/headers/server.h b/headers/server.h
index 1294953185523bda895a0aa91f458c6c3a6726fc..0eb13092dc463f8a3ea8c1c735a815697aec8b39 100644
--- a/headers/server.h
+++ b/headers/server.h
@@ -2,6 +2,7 @@
 #ifndef _SERVER_
 #define _SERVER_
 
+#include <arpa/inet.h>
 #include <bits/stdc++.h>
 #include <fstream>
 #include <iostream>
@@ -15,11 +16,10 @@
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <sys/stat.h> // For stat() and mkdir() functions
 #include <sys/statvfs.h>
 #include <sys/types.h>
 
-#include <arpa/inet.h>
-
 // include local
 #include "conexao.h"
 #include "frame.h"
@@ -49,6 +49,8 @@ private:
   unsigned long chk_available_size();
   long long receive_file_size(frame *f);
   void start_receveing_message();
+  bool create_received_dir();
+  bool receive_file_name();
 
 public:
   // ------- Construtores ------ //
@@ -152,10 +154,56 @@ long long server::receive_file_size(frame *f) {
   return 1;
 }
 
+bool server::create_received_dir() {
+
+  //check if the directory exists
+  struct stat info;
+  if (stat(FILE_DESTINATION, &info) == 0 && (info.st_mode & S_IFDIR)) {
+    cout << "Diretorio ja existe\n";  
+    return true;
+  }
+
+  //create the directory
+  if (mkdir(FILE_DESTINATION, 0700) == -1) {
+    cout << "Erro ao criar o diretorio\n";
+    return false;
+  } 
+    
+  cout << "Diretorio criado com sucesso\n";
+  return true;
+}
+
+bool server::receive_file_name() { 
+  frame *fReceive;
+
+  // Aguarda receber um frame do tipo midia com o nome do arquivo
+  do {
+    if (!receive_valid_frame(&fReceive))          
+    { 
+      cout << "Timeout, falha ao receber o nome do arquivo. Abortado\n";
+      return false; 
+    }
+
+    if (fReceive->get_tipo() != MIDIA) { continue; }
+
+  } while ( !strncmp(fReceive->get_dado(), "NAME", 4) );
+  
+  cout << "Nome do arquivo recebido com sucesso\n";
+  return true;
+ }
+
+
+
+// void server::receive_file_data(){
+//   vector<frame *> framesMidia;
+//   receive
+
+// };
+
 void server::receive_midia(frame *f) {
-  // if ( !create_received_dir)   { return; }
-  if (!receive_file_size(f)) { return; }
-  // if ( !receive_file_name()    { return; }
+  if ( !create_received_dir() )   { return; }
+  if ( !receive_file_size(f)  )   { return; }
+  if ( !receive_file_name()   )   { return; }
   // receive_file_data();
 }
 
diff --git a/teste b/teste
new file mode 100755
index 0000000000000000000000000000000000000000..8b98f312be08825cee66554aeaa895ef0fff3670
Binary files /dev/null and b/teste differ