Joe Schaefer wrote:
Franky Braem <[EMAIL PROTECTED]> writes:
Is there a step by step tutorial on how to implement a file upload in
an Apache module with apreq2? I'm trying to write mod_wxjs (JavaScript
and wxWidgets as server side script, more info on
wxjs.sourceforge.net) and I want to add a file upload functionality
(something like php).
Something like this:
#include "httpd.h"
#include "apreq_module.h"
#include "apreq_param.h"
#include "apreq_module_apache2.h"
#include "apreq_util.h"
apreq_handle_t *req;
apreq_param_t *param;
request_rec *r;
... initialize r ...
req = apreq_handle_apache2(r);
param = apreq_body_get(req, "name of upload widget");
if (param == NULL) {
/* error: missing field */
}
else if (param->upload == NULL) {
/* error: widget not an upload */
}
else {
/* have upload field */
apr_table_t *info; /* upload headers */
apr_bucket_brigade *bb; /* upload contents */
apr_bucket_t *e;
info = param->info;
/* DO SOMETHING with info */
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
apreq_brigade_copy(bb, param->upload);
while ((e = APR_BRIGADE_FIRST(bb)) != APR_BRIGADE_SENTINEL(bb)) {
apr_size_t dlen;
const char *data;
apr_status_t s;
/* apr_bucket_read() has side effects on spool buckets, which
* is why we read from a copy of the brigade - to conserve memory
*/
s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
if (s != APR_SUCCESS) {
/* error: bad bucket read */
break;
}
else {
/* DO SOMETHING with data, dlen */
}
apr_bucket_delete(e);
}
}
I'm trying to integrate apreq2 into wxJS, but I get the following crash
when trying to handle a request:
> apreq2.dll!apreq_filter_relocate(ap_filter_t * f=0x00000000) Line 48
+ 0x3 bytes C
apreq2.dll!get_apreq_filter(apreq_handle_t * handle=0x05b20938) Line
45 + 0xc bytes C
apreq2.dll!apreq_handle_apache2(request_rec * r=0x015aaad0) Line 435
+ 0x9 bytes C
mod_wxjs.dll!wxjs_handler(request_rec * r=0x015aaad0) Line 287 +
0x9 bytes C++
[EMAIL PROTECTED]() + 0x1f bytes
Is it possible to build libapreq2 with Visual Studio Express 2005?