Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » HTTP Client and file upload
Re: HTTP Client and file upload [message #25584 is a reply to message #18830] Tue, 02 March 2010 13:28 Go to previous messageGo to previous message
forlano is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HttpsClient problems?
Next Topic: HttpQuery - not working?
Goto Forum:
  


Current Time: Thu May 09 19:25:46 CEST 2024

Total time taken to generate the page: 0.01530 seconds