Entwickler-Ecke

Internet / Netzwerk - IdHttp.post error...


chukalv - Mo 15.05.06 09:46
Titel: IdHttp.post error...
Don`t get it what I`m doing wrong. The post method doesn`t work for me...

The php source:

Quelltext
1:
2:
3:
<?
echo $_POST['test'];
?>


The delphi source:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
input, output : Tstringstream;
begin
input := TStringstream.Create('');
output := TStringstream.Create('');
try
input.WriteString('test=helloworld');
Idhttp1.Request.ContentType := 'application/x-www-form-urlencoded';
Idhttp1.Post('http://localhost/testi/aha.php',input,output);
Memo1.lines.LoadFromStream(output);
finally
input.free;
output.free;
end;


As I understood. The output should be ''helloworld', but it allways gives out a blank page.

P.S. In every example that I`v looked there is a URLENcode function mentioned. I`m using Delphi 6 and I don`t have such a built-in funcion...As I know, the urlenocde is neede if there are some other characters like space...


digi_c - Mo 15.05.06 10:16

So you wont to send parameters through a PHP script?
Suche bei Delphi-Treff PER POST DATEN AN SCRIPTS SENDEN (sry in german)


chukalv - Mo 15.05.06 10:57

Thanks. This this one [http://www.dsdt.info/tipps/?id=455] worked for me. Just I don`t understand how to change it for file uploading.. Just sending a variable 'file=C:\test.txt' doesn`t work...
Or am I doing something wrong in the php?

Quelltext
1:
2:
$file = $_POST['file'];
move_uploaded_file($file,'/upload/file.txt');


?