how to find if the file is transferred [modified]
-
Hello , I am sending a gif file to the HTTP Server. Is there any way to find that the file is transfered successfully. If yes how?
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
HANDLE hFile;HINTERNET hSession = InternetOpen(NULL, INTERNET\_OPEN\_TYPE\_PRECONFIG, NULL, NULL, 0); HINTERNET hConnection = InternetConnect(hSession, \_T("www.crmpanel.com"), // Server INTERNET\_DEFAULT\_HTTP\_PORT, NULL, // Username NULL, // Password INTERNET\_SERVICE\_HTTP, 0, // Synchronous NULL); // No Context BufferIn.dwStructSize = sizeof( INTERNET\_BUFFERS ); HINTERNET hRequest = HttpOpenRequest(hConnection, \_T("PUT"), \_T("/temp"), NULL, NULL, NULL, 0, 0); if (!hRequest) { //printf("Failed to open request handle: %lu\\n", GetLastError ()); MessageBox(\_T("Failed to open request handle:"),NULL,MB\_OK); return ; } hFile = CreateFile (\_T("c:\\\\Image1.gif"), GENERIC\_READ, FILE\_SHARE\_READ, NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL); if (hFile == INVALID\_HANDLE\_VALUE) { MessageBox(\_T("Failed to open local file"),NULL,MB\_OK); return ; } BufferIn.dwBufferTotal = GetFileSize(hFile, NULL); MessageBox(\_T("File size is"),NULL,MB\_OK); if(!HttpSendRequestEx(hRequest, &BufferIn, NULL, HSR\_INITIATE, 0)) { MessageBox(\_T("Error on HttpSendRequestEx"),NULL,MB\_OK); return ; } DWORD sum = 0; do { if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer), &dwBytesRead, NULL))) { MessageBox(\_T("ReadFile failed on buffer"),NULL,MB\_OK); break; } if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead, &dwBytesWritten))) { MessageBox(\_T
-
Hello , I am sending a gif file to the HTTP Server. Is there any way to find that the file is transfered successfully. If yes how?
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
HANDLE hFile;HINTERNET hSession = InternetOpen(NULL, INTERNET\_OPEN\_TYPE\_PRECONFIG, NULL, NULL, 0); HINTERNET hConnection = InternetConnect(hSession, \_T("www.crmpanel.com"), // Server INTERNET\_DEFAULT\_HTTP\_PORT, NULL, // Username NULL, // Password INTERNET\_SERVICE\_HTTP, 0, // Synchronous NULL); // No Context BufferIn.dwStructSize = sizeof( INTERNET\_BUFFERS ); HINTERNET hRequest = HttpOpenRequest(hConnection, \_T("PUT"), \_T("/temp"), NULL, NULL, NULL, 0, 0); if (!hRequest) { //printf("Failed to open request handle: %lu\\n", GetLastError ()); MessageBox(\_T("Failed to open request handle:"),NULL,MB\_OK); return ; } hFile = CreateFile (\_T("c:\\\\Image1.gif"), GENERIC\_READ, FILE\_SHARE\_READ, NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL); if (hFile == INVALID\_HANDLE\_VALUE) { MessageBox(\_T("Failed to open local file"),NULL,MB\_OK); return ; } BufferIn.dwBufferTotal = GetFileSize(hFile, NULL); MessageBox(\_T("File size is"),NULL,MB\_OK); if(!HttpSendRequestEx(hRequest, &BufferIn, NULL, HSR\_INITIATE, 0)) { MessageBox(\_T("Error on HttpSendRequestEx"),NULL,MB\_OK); return ; } DWORD sum = 0; do { if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer), &dwBytesRead, NULL))) { MessageBox(\_T("ReadFile failed on buffer"),NULL,MB\_OK); break; } if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead, &dwBytesWritten))) { MessageBox(\_T
Dhiraj kumar Saini wrote:
Is there any way to find that the file is transfered successfully.
If either if the
if()
conditions in thewhile()
loop fail, you know the transfer was unsuccessful."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch