Home » U++ Library support » U++ MT-multithreading and servers » [SOLVED] File upload example
Re: File upload example [message #52439 is a reply to message #52436] |
Sun, 29 September 2019 13:11 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Thanks.
After many tests I was able to perform the wanted operation.
Here is the U++ method
void fileupload::Upload()
{
String url = "http://localhost/uploads/transfer.php";
HttpRequest r(url);
String fn = "C:/upp/out/MyApps/MSBT17.Gui/test.pdf";
String s = LoadFile(fn);
r.POST();
r.Part("file", s , "multipart/form-data", fn);
r.Execute();
}
and this is the PHP script connected with the previous code:
<?php
//transfer.php
$target = "./". basename( $_FILES["file"]["name"] ) ;
if(move_uploaded_file($_FILES["file"]["tmp_name"], $target)) echo "1";
else echo "0";
?>
Is there a way to get the echoed "1" or "0" with r.something()?
Edit: Yes, of course:
String a;
a = r.Execute();
a contains the server answer.
Luigi
[Updated on: Sun, 29 September 2019 16:47] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri May 03 23:05:29 CEST 2024
Total time taken to generate the page: 0.03082 seconds
|