如何预先使用FileUpload controlnks在ftp上上传文件... [英] How to upload a file on ftp using FileUpload controlnks in advance...

查看:91
本文介绍了如何预先使用FileUpload controlnks在ftp上上传文件...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

在此先感谢... :)

我想使用asp .net中的文件上传控件将图像文件上传到ftp上,但我不知道如何上传&使用C#代码在ftp上下载文件...

帮我吧.....

Hello friends

thanks in advance... :)

I want to upload a image file on my ftp using a file upload control in asp .net but i don''t know how to upload & download files on ftp using c# code...

Heml me.....

推荐答案

您没有在FTP上使用文件上传控件:FTP没有UI元素,它全部基于命令,并且因此甚至无法显示控件.


实际上,我正在建立一个客户端要从其系统或任何地方上载文件但该文件未存储在数据库中的站点,必须将其保存在其托管空间中.

告诉我此解决方案有什么问题... ??"



您不需要FTP:只需在页面上添加一个上传控件,然后处理Upload Click事件:

You don''t use a file upload control on FTP: FTP has no UI element, it is all command based, and thus cannot even display the controls.


"actually i''m making a site in which Client want to upload a file from his system or anywhere but the file does not store in database has to be saved on his hosting space.

Tell me what is the problem of this solution...??"



You don''t need FTP for that: just add an upload control to your page, and handle the Upload Click event:

/// <summary>
/// Upload the file to the database.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void butUpload_Click(object sender, EventArgs e)
    {
    StatusLabel.Text = SaveUpload(FileUpload1);
    }
/// <summary>
/// Save an upload into the database.
/// </summary>
/// <param name="fl">Control containing the download.</param>
/// <returns>Status as a string</returns>
private string SaveUpload(FileUpload fl)
    {
    if (fl.HasFile)
        {
        try
            {
            int version = 0;
            string filename = Path.GetFileName(fl.FileName);
            byte[] filedata = fl.FileBytes;

(其余的与您无关,因为它通过版本控制保存到数据库中)
掌握了这两点信息后,就可以将其保存在他的Web主机上所需的位置.

(The rest of this is irrelevant to you, as it saves to a DB, with version control)
Once you have these two bits of info, you can save it where you need to on his web host.


这篇关于如何预先使用FileUpload controlnks在ftp上上传文件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆