title: How to get filename from http request body string?
body: <p>So I try such code:</p>
  
  <pre><code>std::ofstream myfile;
  myfile.open ("example.txt", std::ios_base::app );
  myfile  &lt;&lt; "Request body: " &lt;&lt; request-&gt;body &lt;&lt; std::endl &lt;&lt; "Request size: " &lt;&lt;  request-&gt;body.length() &lt;&lt; std::endl;
  
  size_t  found_file = request-&gt;body.find("filename=");
  if (found_file != std::string::npos)
  {
      size_t  end_of_file_name = request-&gt;body.find("\"",found_file + 1);
      if (end_of_file_name != std::string::npos)
      {
          std::string filename(request-&gt;body, found_file+10, end_of_file_name - found_file);
          myfile &lt;&lt; "Filename == " &lt;&lt;   filename &lt;&lt; std::endl;
      }
  }
  myfile.close();
  </code></pre>
  
  <p>But it outputs in for example:</p>
  
  <pre><code>Request body: ------WebKitFormBoundary0tbfYpUAzAlgztXL
  
  Content-Disposition: form-data; name="datafile"; filename="Torrent downloaded from Demonoid.com.txt"
  
  Content-Type: text/plain
  
  
  
  Torrent downloaded from http://www.Demonoid.com
  
  ------WebKitFormBoundary0tbfYpUAzAlgztXL--
  
  
  Request size: 265
  Filename == Torrent d
  </code></pre>
  
  <p>This means that from <code>filename="Torrent downloaded from Demonoid.com.txt"</code> my cede returnes <code>Torrent d</code> as a file name while it should return  <code>Torrent downloaded from Demonoid.com.txt</code>. How to fix my file upload http request filename parser?</p>