当前位置:首页 » 文件管理 » vcftp文件上传

vcftp文件上传

发布时间: 2023-05-30 11:28:46

Ⅰ 如何使用ftp上传文件

1、下载软件FileZilla(用的比较多的一款),

Ⅱ C语言实现从FTP下载、上传文件

FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”。
1.C语言可以使用CStdioFile函数打开本地文件。使用类CInternetSession 创建并初始化一个Internet打开FTP服务器文件。
CStdioFile继承自CFile,一个CStdioFile 对象代表一个用运行时函数fopen 打开的C 运行时流式文件。
流式文件是被缓冲的,而且可以以文本方式(缺省)或二进制方式打开。文本方式提供对硬回车—换行符对的特殊处理。当你将一个换行符(0x0A)写入一个文本方式的CStdioFile 对象时,字节对(0x0D,0x0A)被发送给该文件。当你读一个文件时,字节对(0x0D,0x0A)被翻译为一个字节(0x0A)。
CStdioFile 不支持Duplicate,LockRange,和UnlockRange 这几个CFile 函数。如果在CStdioFile 中调用了这几个函数,将会出现CNoSupported 异常。
使用类CInternetSession 创建并初始化一个或多个同时的Internet 会话。如果需要,还可描述与代理服务器的连接。
如果Internet连接必须在应用过程中保持着,可创建一个类CWinApp的CInternetSession成员。一旦已建立起Internet 会话,就可调用OpenURL。CInternetSession会通过调用全局函数AfxParseURL来为分析映射URL。无论协议类型如何,CInternetSession 解释URL并管理它。它可处理由URL资源“file://”标志的本地文件的请求。如果传给它的名字是本地文件,OpenURL 将返回一个指向CStdioFile对象的指针。
如果使用OpenURL在Internet服务器上打开一个URL,你可从此处读取信息。如果要执行定位在服务器上的指定的服务(例如,HTTP,FTP或Gopher)行为,必须与此服务器建立适当的连接。

Ⅲ VC6.0下,FTP文件上传出错,请问如何得到错误信息

首先,用
GetLastError
()
函数得到
错误代码
,然后在网上找找解决方法;如果这样不行的话,那就再用
InternetGetLastResponseInfo()
函数得到错误信息,两者结合起来,一般就能解决问题了。

Ⅳ FTP 服务器怎么上传文件

ftp服务器上传文件,用毁拦到的工具:8uftp,步骤如下:

  1. 打开8uftp。


注意事项:压缩文件绝侍以加快上传速度,上传的纤宏胡时候选择二进制防止丢包。

Ⅳ c# FTP上传文件

C#ftp上传,参考如下:
///<summary>
///上传文件
///</summary>/
//<paramname="fileinfo">需要上传的文件</param>
///<paramname="targetDir">目标路径</param>
///<paramname="hostname">ftp地址</param>/
//<paramname="username">ftp用户名</param>/
//<paramname="password">ftp密码</param>
publicstaticvoidUploadFile(FileInfofileinfo,stringtargetDir,stringhostname,stringusername,stringpassword)
{//1.checktarget
stringtarget;
if(targetDir.Trim()=="")
{return;}
target=Guid.NewGuid().ToString();
//使用临时文件名
森乎嫌stringURI="FTP://"+hostname+"/"+targetDir+"/"+target;
///WebClientwebcl=newWebClient();
System.Net.FtpWebRequestftp=GetRequest(URI,username,password);
//设置FTP命令设置所要执行的FTP命令,
//ftp.Method=System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;//假设此处为显示指定路径下的文件列表
ftp.Method=System.Net.WebRequestMethods.Ftp.UploadFile;
//指定文件传输的数据类型
ftp.UseBinary=true;
ftp.UsePassive=true;//告诉ftp文件大小
ftp.ContentLength=fileinfo.Length;
//缓冲大小设置为2KB
constintBufferSize=2048;
byte[]content=newbyte[BufferSize-1+1];
intdataRead;//打开一个文件流(System.IO.FileStream)去读上传的文件
using(FileStreamfs=fileinfo.OpenRead())
{
try{//把上顷橡传的文件写入流
using(Streamrs=ftp.GetRequestStream())
{do
{//每次读文件流的2KB
dataRead=fs.Read(content,0,BufferSize);rs.Write(content,0,dataRead);}
while(!(dataRead<BufferSize));rs.Close();}}
catch(Exceptionex){}finally{fs.Close();}}
ftp=null;//设置FTP命令
ftp=GetRequest(URI,username,password);
ftp.Method=System.Net.WebRequestMethods.Ftp.Rename;//改名
ftp.RenameTo=此手fileinfo.Name;try{ftp.GetResponse();}
catch(Exceptionex)
{
ftp=GetRequest(URI,username,password);ftp.Method=System.Net.WebRequestMethods.Ftp.DeleteFile;//删除
ftp.GetResponse();throwex;}finally
{
//fileinfo.Delete();}//可以记录一个日志"上传"+fileinfo.FullName+"上传到"+"FTP://"+hostname+"/"+targetDir+"/"+fileinfo.Name+"成功.");
ftp=null;
#region
/******FtpWebResponse*****///FtpWebResponseftpWebResponse=(FtpWebResponse)ftp.GetResponse();
#endregion
}
///<summary>
///下载文件
///</summary>
///<paramname="localDir">下载至本地路径</param>
///<paramname="FtpDir">ftp目标文件路径</param>
///<paramname="FtpFile">从ftp要下载的文件名</param>
///<paramname="hostname">ftp地址即IP</param>
///<paramname="username">ftp用户名</param>
///<paramname="password">ftp密码</param>
publicstaticvoidDownloadFile(stringlocalDir,stringFtpDir,stringFtpFile,stringhostname,stringusername,stringpassword)
{
stringURI="FTP://"+hostname+"/"+FtpDir+"/"+FtpFile;
stringtmpname=Guid.NewGuid().ToString();
stringlocalfile=localDir+@""+tmpname;

System.Net.FtpWebRequestftp=GetRequest(URI,username,password);
ftp.Method=System.Net.WebRequestMethods.Ftp.DownloadFile;
ftp.UseBinary=true;
ftp.UsePassive=false;

using(FtpWebResponseresponse=(FtpWebResponse)ftp.GetResponse())
{
using(StreamresponseStream=response.GetResponseStream())
{
//looptoread&writetofile
using(FileStreamfs=newFileStream(localfile,FileMode.CreateNew))
{
try
{
byte[]buffer=newbyte[2048];
intread=0;
do
{
read=responseStream.Read(buffer,0,buffer.Length);
fs.Write(buffer,0,read);
}while(!(read==0));
responseStream.Close();
fs.Flush();
fs.Close();
}
catch(Exception)
{
//
fs.Close();
//deletetargetfileasit'sincomplete
File.Delete(localfile);
throw;
}
}

responseStream.Close();
}

response.Close();
}try
{
File.Delete(localDir+@""+FtpFile);
File.Move(localfile,localDir+@""+FtpFile);


ftp=null;
ftp=GetRequest(URI,username,password);
ftp.Method=System.Net.WebRequestMethods.Ftp.DeleteFile;
ftp.GetResponse();

}
catch(Exceptionex)
{
File.Delete(localfile);
throwex;
}

//记录日志"从"+URI.ToString()+"下载到"+localDir+@""+FtpFile+"成功.");
ftp=null;
}

///<summary>
///搜索远程文件
///</summary>
///<paramname="targetDir"></param>
///<paramname="hostname"></param>
///<paramname="username"></param>
///<paramname="password"></param>
///<paramname="SearchPattern"></param>
///<returns></returns>
publicstaticList<string>ListDirectory(stringtargetDir,stringhostname,stringusername,stringpassword,stringSearchPattern)
{
List<string>result=newList<string>();
try
{
stringURI="FTP://"+hostname+"/"+targetDir+"/"+SearchPattern;

System.Net.FtpWebRequestftp=GetRequest(URI,username,password);
ftp.Method=System.Net.WebRequestMethods.Ftp.ListDirectory;
ftp.UsePassive=true;
ftp.UseBinary=true;


stringstr=GetStringResponse(ftp);
str=str.Replace(" "," ").TrimEnd(' ');
str=str.Replace(" "," ");
if(str!=string.Empty)
result.AddRange(str.Split(' '));

returnresult;
}
catch{}
returnnull;
}

(FtpWebRequestftp)
{
//Gettheresult,streamingtoastring
stringresult="";
using(FtpWebResponseresponse=(FtpWebResponse)ftp.GetResponse())
{
longsize=response.ContentLength;
using(Streamdatastream=response.GetResponseStream())
{
using(StreamReadersr=newStreamReader(datastream,System.Text.Encoding.Default))
{
result=sr.ReadToEnd();
sr.Close();
}

datastream.Close();
}

response.Close();
}

returnresult;
}
///在ftp服务器上创建目录
///</summary>
///<paramname="dirName">创建的目录名称</param>
///<paramname="ftpHostIP">ftp地址</param>
///<paramname="username">用户名</param>
///<paramname="password">密码</param>
publicvoidMakeDir(stringdirName,stringftpHostIP,stringusername,stringpassword)
{
try
{
stringuri="ftp://"+ftpHostIP+"/"+dirName;
System.Net.FtpWebRequestftp=GetRequest(uri,username,password);
ftp.Method=WebRequestMethods.Ftp.MakeDirectory;

FtpWebResponseresponse=(FtpWebResponse)ftp.GetResponse();
response.Close();
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
///<summary>
///删除目录
///</summary>
///<paramname="dirName">创建的目录名称</param>
///<paramname="ftpHostIP">ftp地址</param>
///<paramname="username">用户名</param>
///<paramname="password">密码</param>
publicvoiddelDir(stringdirName,stringftpHostIP,stringusername,stringpassword)
{
try
{
stringuri="ftp://"+ftpHostIP+"/"+dirName;
System.Net.FtpWebRequestftp=GetRequest(uri,username,password);
ftp.Method=WebRequestMethods.Ftp.RemoveDirectory;
FtpWebResponseresponse=(FtpWebResponse)ftp.GetResponse();
response.Close();
}
catch(Exceptionex)
{

MessageBox.Show(ex.Message);
}
}
///<summary>
///文件重命名
///</summary>
///<paramname="currentFilename">当前目录名称</param>
///<paramname="newFilename">重命名目录名称</param>
///<paramname="ftpServerIP">ftp地址</param>
///<paramname="username">用户名</param>
///<paramname="password">密码</param>
publicvoidRename(stringcurrentFilename,stringnewFilename,stringftpServerIP,stringusername,stringpassword)
{
try
{

FileInfofileInf=newFileInfo(currentFilename);
stringuri="ftp://"+ftpServerIP+"/"+fileInf.Name;
System.Net.FtpWebRequestftp=GetRequest(uri,username,password);
ftp.Method=WebRequestMethods.Ftp.Rename;

ftp.RenameTo=newFilename;
FtpWebResponseresponse=(FtpWebResponse)ftp.GetResponse();

response.Close();
}
catch(Exceptionex){MessageBox.Show(ex.Message);}}
(stringURI,stringusername,stringpassword)
{
//根据服务器信息FtpWebRequest创建类的对象
FtpWebRequestresult=(FtpWebRequest)FtpWebRequest.Create(URI);
//提供身份验证信息
result.Credentials=newSystem.Net.NetworkCredential(username,password);
//设置请求完成之后是否保持到FTP服务器的控制连接,默认值为true
result.KeepAlive=false;
returnresult;
}

Ⅵ 怎么用cftpconnection类编写向ftp server上传文件

为了与FTP Internet服务器通讯,必须先创建一个CInternetSession实例,然后创建CFtpConnection对象。创建CFtpConnection对象不采用直接方式,而是调用CInternetSession::GetFtpConnertion来创建并返回一个指向它的指针。

CFtpConnection类的成员

构造函数 CFtpConnection 构造一个CFtpConnection对象

操作 SetCurrentDirectory 设置当前FTP目录

GetCurrentDirectory 获取此次连接的当前目录

GetCurrentDirectoryAsURL 获取作为URL的此次连接的当前目录

RemoveDirectory 从服务器移去指定目录

CreateDirectory 在服务器上构造一个目录

Rename 将服务器上的文件改名

Remove 从服务器上移去一个文件

PutFile 将一个文件放到服务器上

GetFile 从连接的服务器上获取一个文件

OpenFile 在连接的服务器上打开一个文件

Close 关闭与服务器的连接

实例一:上传文件
CString strAppName = AfxGetAppName();
CInternetSession* pSession = new CInternetSession(strAppName);
CFtpConnection* pConn = pSession->GetFtpConnection("
10.46.1.232","Anonymous","",21);
pConn->SetCurrentDirectory("test");
CString strLocfile,strRemotefile;
strLocfile="C:\\cmd.txt";
strRemotefile="cmd.txt";
pConn->PutFile(strLocfile,strRemotefile,FTP_TRANSFER_TYPE_ASCII);
pConn->Close();
return 0;
实例二:Ftp的打开文件操作函数:OpenFile

Ⅶ 如何用C++实现FTP文件上传的程序

给你个例子
#include <afxinet.h>
void main()
{
BOOL dRes,pRes;
HINTERNET hInternet;
HINTERNET hConnect;
hInternet = InternetOpen("A3GS Sample", INTERNET_OPEN_TYPE_DIRECT,
NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
if ( NULL == hInternet )
{
printf("InternetOpen Error:%d\n", GetLastError() );
}
hConnect = InternetConnect(hInternet, "洞历散127.0.0.1", INTERNET_DEFAULT_FTP_PORT,
"ww123", "12345", INTERNET_SERVICE_FTP,
INTERNET_FLAG_EXISTING_CONNECT || INTERNET_FLAG_PASSIVE,0 );
if ( NULL == hInternet )
{
printf( "InternetConnect Error:%d\n", GetLastError() );
InternetCloseHandle(hInternet);
}

dRes = FtpGetFile(hConnect, "./wwyy/download/test1.txt", "D:\\BT\\test1.txt", FALSE,
FILE_ATTRIBUTE_ARCHIVE, FTP_TRANSFER_TYPE_UNKNOWN, 0);
if ( dRes == 0 )
{
printf( "FtpGetFile Error:\n", GetLastError() );
}else{
printf( "下载文件成纳氏功!\n" );
}
pRes = FtpPutFile(hConnect,"D:\\BT\\hhsj.txt","hhsj.txt",FTP_TRANSFER_TYPE_ASCII,0);
if(pRes==0)
{
printf("上传文件失败!\n");
}else{
printf("上传文件烂数成功!\n");
}
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
if(dRes&&pRes) return true;
else return false;

Ⅷ ftp命令怎么上传文件夹

1、输入命令行:--> FTP 10.1.61.212 如果对方没有开启FTP服务,那么这个命令就不会有效果。

Ⅸ ftp 怎样上传

FTP上传是通过ftp协议把文件从本地电脑和远程服务器传输的过程,包括上传和下载的过程。

文件类型很多了,任何文件都可以上传下载。

你可以在服务器端部署ftp服务端程序,给对方开一个新的ftp账号,把ip和账号信息告诉对方,他就可以用来上传文件了。

和别人共用服务器时采用这种方法,可以把对方的权限限制在某个文件夹里面,他只能在这里上传下载文件,对于服务器安全、权限都有保障。

Ⅹ ftp怎么设置上传文件

其功能比较复杂,这里只就文件上传设定的方式作个说明。
[语法] upload [absolute|relative] [class=]... [-]
["dirs"|"nodirs"] []
[说明] 定义这个目录是允许或拒绝上传。假如允许上传的话,则所有的文件是及所拥有,而且其文件权限是。
例如:upload /var/ftp * no
upload /var/ftp /incoming yes ftp daemon 0666
upload /var/ftp /incoming/gifs yes jlc guest 0600 nodirs
上面的设置只允许文件上传到/incoming及/incomeing/gifs这二个目录,被上传到/incoming的文件其所有权将是ftp/daemon,而其权限是0666;被上传到/incoming/gifs的文件,其所有权将是jlc/guest,而其权限是0600。注意是指ftp目录;必须跟系统密码文件内 (/etc/passwd) 的使用者目录一致。
此外,dirs及nodirs这二个选项可有可无。这二个选项是指:允许(dirs)或不允许(nodirs)使用mkdir这个指令来产生新的子目录。
注意,假如不指明的话,“产生新的子目录”这个权限是默认是被允许的。
这个选项决定新产生子目录的权限。假如被省略,则目录权限将会是;若是也没有的话,则新产生子目录的权限将是777。
注意,上传这个功能只对"用户主目录" (或使用者的根目录?) 在底下的使用者有效。假如把设为"*"的话,则不受此限制。更进一步说明,就是指chroot()这个指令的输入参数。 及也可以设定成"*"。在这个情况下,任何上传的文件及新产生子目录的所有权将被设置成与其所在的上层目录所有权一致。
[absolute|relative]
这个选项可有可无。这个选项定义这个目录将被解释为绝对路径 (absolute),或是目前chroot环境的相对路径 (relative)。预设是绝对路径 (absolute)。
这个选项一定要有。yes是指允许上传,反之则禁止

热点内容
我的世界服务器自动扫地 发布:2024-05-04 03:48:41 浏览:610
4500能配什么电脑配置 发布:2024-05-04 03:22:29 浏览:590
阿U编程课堂 发布:2024-05-04 03:10:23 浏览:617
上传音乐搜音乐 发布:2024-05-04 03:10:23 浏览:599
编译器工作负载 发布:2024-05-04 03:06:09 浏览:421
摩斯编译 发布:2024-05-04 03:06:00 浏览:612
源码得反码 发布:2024-05-04 03:05:18 浏览:752
手机搜狐怎么上传视频 发布:2024-05-04 02:50:54 浏览:74
存储卡那里有卖 发布:2024-05-04 02:45:42 浏览:967
磁盘存储介质 发布:2024-05-04 02:44:19 浏览:435