首页 > 解决方案 > WinInet上传文件PHP

问题描述

我有以下问题,我是如何通过 Wininet.dll 发送图像的新手。

我正在使用 metatrader 4(C 语言),并且我与 PHP 的连接成功,但我没有在服务器上收到附件。

附上代码:

元交易者 4:

string frmdata = "-----------------------------7d82751e2bc0858\r\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"C:\\Users\descarga.png\"\r\nContent-Type: "+filetype+"\r\n\r\nfile contents  here\r\n-------------------------------7d82751e2bc0858\r\n";
string hdrs = "Content-Type: multipart/form-data; boundary=---------------------------7d82751e2bc0858";
#import  "Wininet.dll"
      int HttpOpen = InternetOpenW(InternetAgent, Internet_Open_Type_Direct, "0", "0", "0");
      int HttpConnect = InternetConnectW(HttpOpen, "Localhost", 8080, "", "", 3, 0, 1);
      int HttpRequest = HttpOpenRequestW(HttpConnect, "POST", "/ConnectMT4/funcphp/screenpost.php", "HTTP/1.1", "", acceptTypes, 0, 1);
      bool result = HttpSendRequestW(HttpRequest, hdrs, StringLen(hdrs), frmdata, StringLen(frmdata));
      int read[1];
      Print("This is the POST result: ", result);
      InternetCloseHandle(HttpOpen);
      InternetCloseHandle(HttpRequest);
     }
   return(res==200);
  }

PHP 文件:

<?php
$desprendible = $_FILES["uploadedfile"];

if ($_FILES['uploadedfile']['name'] != null) {
echo "Tiene datos La variable";
}else{
echo "No hay datos";
}
?>

PHP代码,我一直在尝试不同的代码,这是我拥有的最后一个。PHP文件调试的附件照片:https ://prnt.sc/1mm1oh1

标签: phpc++wininet

解决方案


推荐阅读