又是上传文件问题,但绝对不同。远程上传文件失败!(源码奉上)
下面是我上传文件的一个函数:serverFilePath是上传到服务器的目录,clientPathFileName是客户端的完全文件名(包括目录)
protected void UpLoadFile(string serverFilePath, string clientPathFileName)
{
WebClient webClient = new WebClient();
if (!File.Exists(serverFilePath))
{
Directory.CreateDirectory(serverFilePath);
}
string[] arrCurrentFileName = ( string[] ) clientPathFileName.Split( '\\' );
string fileName = arrCurrentFileName[ arrCurrentFileName.GetUpperBound( 0 ) ];
webClient.UploadFile(serverFilePath + fileName ,clientPathFileName);
}
调试时是服务器与客户端是在同一计算机上,上传成功!!
但在另一台计算机,用IE运行我服务器上的程序,也上传同样的文件(大小一样),但总是提示:WebClient请求期间发生异常!
谁救我呀!
protected void UpLoadFile(string serverFilePath, string clientPathFileName)
{
WebClient webClient = new WebClient();
if (!File.Exists(serverFilePath))
{
Directory.CreateDirectory(serverFilePath);
}
string[] arrCurrentFileName = ( string[] ) clientPathFileName.Split( '\\' );
string fileName = arrCurrentFileName[ arrCurrentFileName.GetUpperBound( 0 ) ];
webClient.UploadFile(serverFilePath + fileName ,clientPathFileName);
}
调试时是服务器与客户端是在同一计算机上,上传成功!!
但在另一台计算机,用IE运行我服务器上的程序,也上传同样的文件(大小一样),但总是提示:WebClient请求期间发生异常!
谁救我呀!
...全文
相关推荐
java上传文件接口调用源码案例
**错误处理**: 文件上传可能会遇到各种问题,例如网络连接失败、超时、服务器返回错误代码等。因此,良好的错误处理机制是必要的,包括异常捕获、重试逻辑以及日志记录。7.
C#大文件分块上传源码
这种方法能够有效避免网络中断导致整个文件上传失败,并且可以提高上传速度,因为多个块可以并发上传。在这个“C#大文件分块上传源码”中,主要涉及以下几个关键知识点:1.
简单的PHP文件上传源码
总之,这个简单的PHP文件上传源码是一个很好的学习起点,它涵盖了文件上传的基本流程,对于初学者来说,通过阅读和理解源码中的注释,可以快速掌握PHP文件上传的核心知识。
多文件上传系统源码下载
**错误处理和反馈**:良好的错误处理机制和用户反馈至关重要,可以提示用户上传失败的原因,并提供解决方案。以上是对"多文件上传系统源码"的相关知识点的详细阐述,希望能为你的理解和开发提供帮助。
php文件上传源码
以上就是关于PHP文件上传源码的关键知识点,实际应用中,还需要考虑安全性问题,如防止文件覆盖、SQL注入等。同时,根据业务需求,还可以实现多文件上传、进度条显示等功能。


