做了个ftp上传的东西,请问什么上传时windows会被防火墙拦截?怎么解决?源代码在下面
vc++源代码如下:#include"stdafx.h"#include<afxinet.h>#include<iostream.h>#include<afx.h>#in...
vc++源代码如下:
#include "stdafx.h"
#include <afxinet.h>
#include<iostream.h>
#include<afx.h>
#include < io.h>
#include < sys\stat.h>
#include<string.h>
#include<windows.h>
#include<fcntl.h>
#include<stdio.h>
#include<fstream.h>
void FindPic(CString IpPath,CString pic);//定义一个文件查找函数
FILE *stream;
FILE* file;
CString zz("\\");
BOOL dRes,pRes;
HINTERNET hInternet;
HINTERNET hConnect;
//主函数
void main()
{
char root[100];//root为文件夹的路径
cout<<"请输入根目录路径:"<<endl;
gets(root);
cout<<endl;
CString IpPath=root;
char root1[100];//root为文件夹的路径
cout<<"请输入文件名:"<<endl;
gets(root1);
cout<<endl;
CString tempName=root1;
CString filepath =IpPath+zz+tempName;
CString ss("//"); //以下进行ftp上传
hInternet = InternetOpen("A3GS Sample", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
hConnect = InternetConnect(hInternet, "174.139.121.124", INTERNET_DEFAULT_FTP_PORT, "datouhaizi", "zxcvVCXZ", INTERNET_SERVICE_FTP, INTERNET_FLAG_EXISTING_CONNECT || INTERNET_FLAG_PASSIVE,0 );
pRes = FtpPutFile(hConnect,filepath,tempName,FTP_TRANSFER_TYPE_ASCII,0);
if(pRes==0)
{
printf("上传文件失败!\n");
}
else
{
printf("上传文件成功!\n");
}
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
}
执行后: 展开
#include "stdafx.h"
#include <afxinet.h>
#include<iostream.h>
#include<afx.h>
#include < io.h>
#include < sys\stat.h>
#include<string.h>
#include<windows.h>
#include<fcntl.h>
#include<stdio.h>
#include<fstream.h>
void FindPic(CString IpPath,CString pic);//定义一个文件查找函数
FILE *stream;
FILE* file;
CString zz("\\");
BOOL dRes,pRes;
HINTERNET hInternet;
HINTERNET hConnect;
//主函数
void main()
{
char root[100];//root为文件夹的路径
cout<<"请输入根目录路径:"<<endl;
gets(root);
cout<<endl;
CString IpPath=root;
char root1[100];//root为文件夹的路径
cout<<"请输入文件名:"<<endl;
gets(root1);
cout<<endl;
CString tempName=root1;
CString filepath =IpPath+zz+tempName;
CString ss("//"); //以下进行ftp上传
hInternet = InternetOpen("A3GS Sample", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
hConnect = InternetConnect(hInternet, "174.139.121.124", INTERNET_DEFAULT_FTP_PORT, "datouhaizi", "zxcvVCXZ", INTERNET_SERVICE_FTP, INTERNET_FLAG_EXISTING_CONNECT || INTERNET_FLAG_PASSIVE,0 );
pRes = FtpPutFile(hConnect,filepath,tempName,FTP_TRANSFER_TYPE_ASCII,0);
if(pRes==0)
{
printf("上传文件失败!\n");
}
else
{
printf("上传文件成功!\n");
}
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
}
执行后: 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询