Hello everyone.
I am trying to use WinHttpRequest to upload a file but it is not working.
this is the code i have, it gives me a response of 200 but the file isn't uploaded.
The VFP Code
The code in upload.php
can anyone help please.
thanks.
Sorry for my English
I am trying to use WinHttpRequest to upload a file but it is not working.
this is the code i have, it gives me a response of 200 but the file isn't uploaded.
The VFP Code
Code:
filecontent = FileToStr(ficheiro)
loHTTP = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
loHTTP.Open("POST", "[URL unfurl="true"]http://site.com/webspace/upload.php",[/URL] .F.)
loHTTP.SetRequestHeader("content-type", "text/plain") && or other mime types for other file types.
varrequest = 'attachment; filename="' + JUSTFNAME(ficheiro) + '"'
loHTTP.SetRequestHeader("content-disposition", varrequest)
loHTTP.Send(filecontent)
WAIT WINDOW loHTTP.status
The code in upload.php
PHP:
<?php
$uploaddir = 'upload/';
$uploadfile = $uploaddir . $_FILES['file']['name'];
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File successfully uploaded.\n";
}
?>
can anyone help please.
thanks.
Sorry for my English