Home » U++ Library support » U++ MT-multithreading and servers » HTTP Client and file upload
HTTP Client and file upload [message #18829] |
Sat, 25 October 2008 16:37 |
mdelfede
Messages: 1307 Registered: September 2007
|
Ultimate Contributor |
|
|
Well, I got some problems with http client on a file upload operation.
At first, I had to add
in httpcli.cpp, line 131 in order to avoid a "resource temporary unavailable" error.
Now I can upload small and medium (let's say, some tenth of KBytes) files without problem, but if I try to send a file of around 800 KBytes, the server says "file partially transmitted".
I do have a MAX_UPLOAD of about 40 MBytes on server, and the original web app (that I'm trying to mimick) does it well.
Any hint ?
Max
|
|
|
|
Re: HTTP Client and file upload [message #25584 is a reply to message #18830] |
Tue, 02 March 2010 13:28 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
I am resuming a Max very old post that looks related to my problem. I want to upload a file to a server where there is the postfile.php that looks like this
<html><head></head><body>
<?php
if (!isset($_POST['file'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Enter file path <input type="text" name="file">
</form>
<?php
}
else {
echo 'File name: '.$_POST['file'] .'<br />';
}
?>
</body></html>
I would like to use the HttpClient class to simulate the file upload. I tried the following code after a search on the forum
#include <Web/Web.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
HttpClient x;
x.Method(HttpClient::METHOD_POST);
x.URL("http://localhost/test/postfile.php");
//x.AddHeaders("Content-Type: application/x-www-form-urlencoded");
x.KeepAlive(true);
x.Post("file", LoadFile("myfile.txt"));
String respond = x.ExecuteRedirect();
SaveFile("headers.txt",x.GetHeaders());
SaveFile("respond.html",respond);
}
It simply hangs without result but should be not very far from the right solution.
Thank you for any suggestion,
Luigi
EDIT: it seems to work after the comment of the line with
x.AddHeaders()
[Updated on: Tue, 02 March 2010 21:42] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 20 11:31:00 CEST 2024
Total time taken to generate the page: 0.02800 seconds
|