I get the "Error: could not check file size". Any idea why?
// Generate Content-Length int file_size; int fd; char clenbuf[BUFLEN]; struct stat fs; fd = open(filename, "r"); if (fstat(fd, &fs) == -1) { printf("Error: could not check file size\n"); return; } file_size = fs.st_size; sprintf(clenbuf, "Content-Length: %d", file_size);
openwas successful or not. Also you're getting confused betweenfopenandopen. Try turning on compiler warnings too.fopen()call before just going ahead and using it? It doesn't just magically always manage to open everything you pass it infilename.