问题描述
- 求解文件上传的路径问题
- ///
/// 上传文件
///
/// 上传Token
/// key
/// 本地文件名
public CallRet PutFile(string upToken string localFile string key)
{
if (!File.Exists(localFile))
{
throw new Exception(string.Format(""{0} does not exist"" localFile));
}PutAuthClient client = new PutAuthClient(upToken); CallRet ret; using (FileStream fs = File.OpenRead(localFile)) { int block_cnt = block_count(fs.Length); long fsize = fs.Length; extra.Progresses = new BlkputRet[block_cnt]; byte[] byteBuf = new byte[BLOCKSIZE]; int readLen = BLOCKSIZE; for (int i = 0; i < block_cnt; i++) { if (i == block_cnt - 1) { readLen = (int)(fsize - (long)i * BLOCKSIZE); } fs.Seek((long)i * BLOCKSIZE SeekOrigin.Begin); fs.Read(byteBuf 0 readLen); BlkputRet blkRet = ResumableBlockPut(client byteBuf i readLen); if (blkRet == null) { extra.OnNotifyErr(new PutNotifyErrorEvent(i readLenMake Block Error"")); } else { extra.OnNotify(new PutNotifyEvent(i readLen extra.Progresses[i])); } } ret = Mkfile(client key fsize); } if (ret.OK) { if (PutFinished != null) { PutFinished(this ret); } } else { if (PutFailure != null) { PutFailure(this ret); } } return ret; }
参数localfile应该是文件的绝对路径,如果用input:file 上传,后台怎么获取上传文件的绝对路径赋给这个参数啊?
解决方案
一些浏览器不会发送上传路径,而且客户端的路径对你来说也没有意义。
时间: 2025-01-31 01:30:40