我试图将文件上传到我的网站,认为它的网址是http://mywebsite.com/index.php
我在Windows 8上使用Visual Studio 2013,这是我的代码(main.cpp):
#define CURL_STATICLIB
#pragma comment(lib, "libcurl_a.lib")
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
int main() {
CURL *curl;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
curl_global_init(CURL_GLOBAL_ALL);
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_FILE, "C:\\Users\\User\\Desktop\\uploadme.txt",
CURLFORM_END);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://mywebsite.com/index.php");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_perform(curl); //here it crashes
}
}
当我调试它时,输出是
'TestUpload.exe' (Win32): Loaded 'C:\Users\User\Desktop\TestUpload\Debug\TestUpload.exe'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Wldap32.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\normaliz.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nsi.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded.
'TestUpload.exe' (Win32): Loaded 'C:\Windows\SysWOW64\secur32.dll'. Symbols loaded.
HEAP[TestUpload.exe]: Invalid address specified to RtlValidateHeap( 01170000, 011931F8 )
TestUpload.exe has triggered a breakpoint.
我已经查看了其他主题,但我无法找到问题所在。我是否需要将main.cpp重命名为main.c?
index.php: http://pastebin.com/Zqqm1eJU
注意:这不是恶意程序,只是用于测试。