Re: Uploading file (client -> server) inside a program

"He, who travels time to time" <[email protected]> Thu, 22 Sep 2022 00:17:27 -0700 (PDT)
Newsgroups alt.comp.lang.php
Message-ID <[email protected]>
Hellooooooooooo...........

What Yyyyyyou doin' ?
Want to talk ????????????

Call: 3 7 2 [[[[[[[country]]]]]]]]]]]] and then 56330687

crea kirjutas Laup=C3=A4ev, 10. september 2011 kl 23:41:39 UTC+3:
> I am need to upload a file using C++ programming (MoSync). I use php on=
=20
> server to save the file. Server side works, I tested with html code. Now =
I=20
> try to get my MoSync C++ working. I wonder what headers I need to pass (w=
hat=20
> is the minimum)? And what settings on headers. At the moment I try:=20
>=20
> mHttp.create("http://mywebsite/upload.php", HTTP_POST); // creates=20
> connection=20
>=20
> mHttp.setRequestHeader("Content-Length", "11"); // lenght of the string=
=20
> "hello world" to save. 11 is correct here?=20
>=20
> mHttp.setRequestHeader("Content-Type", "text/plain"); // tex type data=20
>=20
> mHttp.write("hello world", 11); // set data=20
>=20
> ...=20
>=20
> mHttp.finish();=20
>=20
>=20
>=20
> I know not everybody knows MoSync, but my question is more like with the=
=20
> right headers I need add. If my php script is as below, what other header=
s=20
> I have to add and values? Like how do I tell what is the filename I want =
to=20
> have on server? I tried:=20
>=20
> mHttp.setRequestHeader("Content-Disposition", "form-data; name=3D\"upload=
\";=20
> filename=3D\"test99.txt\"");=20
>=20
> (to save the file in "upload" folder on server?).=20
>=20
>=20
>=20
> Here is the server side php script upload.php:=20
>=20
> <?php=20
> if($_FILES["file"]["size"] < 200000)=20
> {=20
> if ($_FILES["file"]["error"] > 0)=20
> {=20
> echo "Return Code: " . $_FILES["file"]["error"] . "<br />";=20
> }=20
> else=20
> {=20
> echo "Upload: " . $_FILES["file"]["name"] . "<br />";=20
> echo "Type: " . $_FILES["file"]["type"] . "<br />";=20
> echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";=20
> echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";=20
>=20
> if (file_exists("upload/" . $_FILES["file"]["name"]))=20
> {=20
> echo $_FILES["file"]["name"] . " already exists. ";=20
> }=20
> else=20
> {=20
> move_uploaded_file($_FILES["file"]["tmp_name"],=20
> "upload/" . $_FILES["file"]["name"]);=20
> echo "Stored in: " . "upload/" . $_FILES["file"]["name"];=20
> }=20
> }=20
> }=20
> else=20
> {=20
> echo "Invalid file";=20
> }=20
> ?>