Hi Tommi

I want to use 
https://github.com/valums/file-uploader#options-of-both-fileuploader--fileuploaderbasic
 
to sent files via XMLHttpRequest (XHR).

How can I receive and save the files using tntnet and XHR?

Previously I used
   const tnt::Multipart& mp = request.getMultipart();
   etc
for multipart posts.

I am now testing this:

<%pre>
#include <fstream>
#include <string>
#include <cxxtools/loginit.h>
#include <cxxtools/log.h>
</%pre>

<%args>
     qqfile;
</%args>

<%cpp>

     log_info("Running fileio...");

     bool vboUploadedFile = false;

     std::string vtxFileName = qqfile;

     if ( vtxFileName != "" ) {

         vboUploadedFile = true;

         log_info("Uploading " + vtxFileName + "...");

         // we found a uploaded file - write it to some upload-area
         std::ofstream out(("../../upload/" + 
vtxFileName).std::string::c_str());

         out << request.getBody();

     }


     if ( vboUploadedFile )
         reply.out( ) << "{\"success\":true}";
     else
         reply.out( ) << "{\"success\": false, \"reason\": \"some 
reason\"}";

</%cpp>

and it does work but I wonder if it is the correct way to do it? (Of 
course it could be so much better...)

I am running Linux.

Actually, it doesn't work sometimes. When uploading from Android 2.2 or 
from IE the files are corrupted. Maybe the body is not what I need.


Using a hex editor the android corrupted image has this at the start of 
the file:
------WebKitFormBoundaryH6z4RWIO2uwriuTB
Content-Disposition: form-data; name="qqfile"; filename="fromRoy2of2.jpg"
Content-Type: image/jpeg....JFIF

whereas the FF (Linux) uploaded file only had the ....JFIF...

Help?


Thank you

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to