经过一天的努力,终于实现了把图片转换成二进制存入mysql了!
兴奋!
代码!
#include <stdio.h>
#include "/usr/local/mysql/include/mysql.h"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define host "192.168.1.214" //mysql server
#define username "zyz"
#define password "12345678"
#define database "gps2008"
int get_file_size(char *path, off_t *size)
{
struct stat file_stats;
if(stat(path, &file_stats))
return -1;
*size = file_stats.st_size;
return 0;
}
int main(int argc, char *argv[])
{
char *filename;
off_t size;
MYSQL *conn;
MYSQL_RES *res_set;
MYSQL_ROW row;
MYSQL_FIELD *field;
int