Actually, it doesn't work sometimes. When uploading from Android 2.2 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?

-------- Original Message --------
Subject: Upload files via XMLHttpRequest (XHR)?
Date: Thu, 20 Sep 2012 09:25:29 -0700
From: Paul <[email protected]>
To: [email protected]


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.

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