Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpSendRequest 12005 error
    primarykey
    data
    text
    <p>i have a tiny program that will upload a file onto a server. for testing purpose i used my own local server which i created by WebAmp software. my program will upload files by using a PHP script that will accept the files from program and stores them on to the server at the specified place. now i am confused on this, that where i have to place this PHP file in my system so that my program will interact with this script and send the file successfully. here is my code </p> <pre><code>int main() { static TCHAR frmdata[] = "-----------------------------7d82751e2bc0858\r\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"D:\\er.txt\"\r\nContent-Type: text/plain\r\n\r\nfile contents here\r\n-----------------------------7d82751e2bc0858--\r\n"; static TCHAR hdrs[] = "Content-Type: multipart/form-data; boundary=---------------------------7d82751e2bc0858"; HINTERNET hSession = InternetOpen("MyBrowser",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(!hSession) { cout&lt;&lt;"Error: InternetOpen"; } HINTERNET hConnect = InternetConnect(hSession, _T("http://localhost"),INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(!hConnect) { cout&lt;&lt;"Error: InternetConnect"; } //HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",_T("upload.php"), NULL, NULL, (const char**)"*/*\0", 0, 1); LPCTSTR rgpszAcceptTypes[] = {_T("*/*"), NULL}; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST", _T("upload.php"), NULL, NULL, rgpszAcceptTypes, 0, 1); if(hRequest==NULL) { cout&lt;&lt;"Error: HttpOpenRequest"; } BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata)); if(!sent) { cout&lt;&lt;"Error: HttpSendRequest "&lt;&lt;GetLastError(); } //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); return 0; } </code></pre> <p>PHP script</p> <pre><code>&lt;?php $uploaddir = './'; // Relative Upload Location of data file if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) { $uploadfile = $uploaddir . basename($_FILES['uploadedfile']['name']); echo "File ". $_FILES['uploadedfile']['name'] ." uploaded successfully. "; if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully moved. "; } else print_r($_FILES); } else { echo "Upload Failed!!!"; print_r($_FILES); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload