i think i figured it out below is the code
string hashi ="files";
ifstream read2("ScannedFiles.txt");
ofstream read3("Problem.txt", ios::app);
vector<string>filen2;
string st2;
while (getline(read2, st2))
{
if (st2.size() > 0)
filen2.push_back(st2);
else
break;
}
read2.close();
int a = filen2.size();
int b = a;
int h = 1;
for (vector<string>::iterator t = filen2.begin(); t != filen2.end(); t++)
{
string st3;
vector<string>upl;
ifstream uploaded("Uploaded.txt", ios::app);
while (getline(uploaded, st3))
{
if (st3.size() > 0)
upl.push_back(st3);
else
break;
}
uploaded.close();
int c = upl.size();
int i = 0;
string currfil = t[i];
string name = getFileName(currfil);
bool toWrite = true;
for (vector<string>::iterator t2 = upl.begin(); t2 != upl.end(); t2++)
{
int j = 0;
if (c <= 0)
break;
else
{
if (t2[j] == currfil)
{
toWrite = false;
}
}
}
if (toWrite == true)
{
CURL *curl;
CURLcode res;
curl_httppost* post = NULL;
curl_httppost* last = NULL;
curl = curl_easy_init();
if (curl)
{
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "Md5",
CURLFORM_COPYCONTENTS, hashi.c_str(),
CURLFORM_END);
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "name2",
CURLFORM_COPYCONTENTS, name.c_str(),
CURLFORM_END);
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "file2",
CURLFORM_FILE, currfil.c_str(),
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:8081/PCInfo/test.php");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);
res = curl_easy_perform(curl);
if (res == 28)
{
read3 << currfil << endl;
}
if (res == 26)
{
read3 << currfil << endl;
}
if (res == 0)
{
ofstream uploaded("Uploaded.txt", ios::app);
uploaded << currfil << endl;
uploaded.close();
}
curl_formfree(post);
}
curl_easy_cleanup(curl);
}
}
return 0;
i am still looking for a more better and clean way because i think it will take too much time