如何从“异步文件上传器控件"中捕获完整的文件路径? [英] How to capture the full file path from Async File Uploader Control?

查看:69
本文介绍了如何从“异步文件上传器控件"中捕获完整的文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在更新面板中的Repeater中有一个异步文件上传器"控件.
我正在将文件上传到ftp,所以我没有使用SaveAs()方法上传视频文件.

为了将文件上传到ftp中,我有一个saveFile方法,该方法带有以下四个参数:FileName,UploadPath,FTPUser,FTPPassword.
对于此FileName,我必须发送完整的文件路径.

我的UploadComplete事件如下所示:

Hi,

I have an Async File Uploader control inside a Repeater which is inside an update panel.
I am uploading the file into ftp, so I am not uploading the video file, using SaveAs() method.

For uploading the file in ftp, I have this saveFile method which takes these four parameter: FileName, UploadPath, FTPUser, FTPPassword.
For this FileName, I have to send the full file path.

My UploadComplete event looks like this:

protected void AsyncVideoUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {//VideoPath is a session variable
        VideoPath = string.Empty;
        if (AsyncVideoUpload.HasFile)
        {
           // string filepath = AsyncVideoUpload.PostedFile.FileName;
            string filepath = e.filename;//above two captures only the file name,but I want the total path,like c:/MyDocuments/...
           
            UploadFile(filepath, "ftp://172.20.117.102", "test", "Value*12");
            VideoPath = AsyncVideoUpload.PostedFile.FileName;
        }
    }



请帮忙.



Please help.

推荐答案

我不确定100%,但是我几乎可以肯定会遇到安全异常.无论如何,您为什么仍需要用户计算机上的完整路径?除非您在FTP上复制源的结构,否则FileUpload组件实际上并不会帮助您.

P.s.甚至Silvelight也不允许您获取文件的完整路径.
I''m not a 100% certain, but I''m almost sure you will get a security exception. Why would you need the full path on the users computer anyway? Unless you were duplicating the structure of the source on the FTP, but then a FileUpload component really isn''t going to get you far.

P.s. Even Silvelight will not allow you to get the full path of a file.


客户端文件路径受保护,您无法获取它.
client file path is protected ,you can''t get it


如果我不提供我的UploadtoFTP()方法的完整Filpath,它将如何读取?
我认为,解决方法是:在硬代码中提供ftp路径(d:/ftp/test),然后将文件名附加到文件中(d:/ftp/test/myfile.png),然后将其发送到UploadtoFTP()方法.
由于我在本地ftp中具有写权限,因此可以将其上传,并且不会出现任何跨浏览器问题.
对于您的信息,IE会捕获完整路径,这与Mozilla FF不同.
If I dont provide the Full Filpath to my UploadtoFTP()method,how will it read it?
The workaround,what I thought,is:giving the ftp path (d:/ftp/test)in the hardcode and appending the filename to it(d:/ftp/test/myfile.png)and send it to UploadtoFTP()method.
Since I have write authority in my local ftp,it can be uploaded and there wont be any cross browser issue.
For your info,IE captures the full path,unlike Mozilla FF.


这篇关于如何从“异步文件上传器控件"中捕获完整的文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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