百独托管7500 紫田网络超高转化播放器收cps[推荐]速盾CDN 免实名免备防屏蔽阿里云 爆款特卖9.9元封顶提升alexa、IP流量7Q5团队
【腾讯云】中小企福利专场【腾讯云】多款产品1折起高防 随时退换 好耶数据小飞国外网赚带你月入万元炎黄网络4H4G10M 99每月
香港带宽CN2/美国站群优惠中客数据中心 服务器租用联盟系统移动广告平台 中易企业专场腾讯云服务器2.5折九九数据 工信部正规资质
腾讯云新用户大礼包代金券高价收cpa注册量高价展示【腾讯云】2核2G/9.93起租服务器找45互联 随时退换阿里云 短信服务 验证秒达

[国内信息] 服务器上传文件失败怎么办?有什么方法解决?121.204.253.35 [复制链接]
查看:310 | 回复:0

74

主题

76

帖子

-10

积分

接近落伍(少量栏能发帖)

贡献
1
鲜花
0
注册时间
2020-10-9

落伍手机绑定

发表于 2020-11-18 17:01:34 | 显示全部楼层 |阅读模式 来自 中国广东东莞
这里的不成功有几种,我是第2种,我分别说明一下:

第1种:出现文件根本无法上传的情况,这是由于无惧上传类v2.2的一个BUG

使用了“无惧上传类 v2.2”,在运行中出现这样一个问题,上传文件时提示上传成功,但文件实际上并没有传上去。然而,如果使用“无惧上传类 v1.2”的话就没有这个问题。经过对比代码,找到了问题的所在,我认为这应该是“无惧上传类 v2.2”的一个BUG。
在UpFile_Class类的SaveToFileEx成员函数中有这样两行:

tmpPath=Split(Path,".")(0)
FileExt=GetFileExt(Path)   
服务器业务咨询QQ:3007491603  火烧云小梁


后面判断若没有问题可以上传,则执行这样一行将文件写到本机中:

oFileStream.SaveToFile tmpPath & "." & FileExt,2

Path是上传的文件在本机的全路径。可以看出,作者的本意是tmpPath的值为文件本机全路径去掉扩展名和连接扩展名的“.”,这样做主要是基于安全上的考虑。然而,实际使用时路径中有一个“.”,如“D:/web/aaa.com/bbb/”,这样,tmpPath的值就是“D:/web/aaa”,这明显是错误的。出现了这样的问题依然提示上传成功的原因是SaveToFileEx函数的开头有一个“On Error Resume Next”。

这样,我们对SaveToFileEx函数进行一些修改,让其先截取路径和文件名,存放于onlyPath和onlyFileName中,再对onlyFileName进行扩展名截取。将tmpPath=Split(Path,".")(0)修改为以下代码:

for i=len(Path) to 1 step -1
if mid(Path, i, 1) = "/" or mid(Path, i, 1) = "/" then exit for
next
onlyPath = left(Path, i)
onlyFileName = right(Path, len(Path) - i)
tmpFileName = Split(onlyFileName,".")(0)

然后将写文件的代码改成这样:

oFileStream.SaveToFile OnlyPath & tmpFileName & "." & FileExt,2

进行了这样的修改,再运行就没有问题了。这个是文件保存路径不对造成的。

第2种:文件上传成功到指定的目录,但无法加载到ubb编辑框里,或者加载到ubb编辑里是个不一样的文件名。

若把upload.asp文件开头的on error resume next去掉,上传文件的过程会出如下错误:
/upload.asp,行300说是无权限 但是明明文件可以上传啊?300行代码是:

Function moveFile(oldfile,newfile)
dim fs
Set fs=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
fs.movefile Server.MapPath(oldfile),Server.MapPath(newfile) (第300行)
Set fs=Nothing
End Function

本地测试文件上传成功,服务器也上传到了指定目录,就是无法这个moveFile函数,这是为什么呢?

有个原因:会不会是服务器上目录结构存在差异,如果跟踪一下Server.MapPath(newfile) ,看这个是否正确?

我测试过,找不出问题,只好不要这个函数,而是直接把上传后的文件名oldfile直接赋给newfile
安溪电信
121.204.253.35
121.204.253.36
121.204.253.37
121.204.253.38
121.204.253.39
121.204.253.40
121.204.253.41
121.204.253.42
121.204.253.43
121.204.253.44
121.204.253.45
121.204.253.46
121.204.253.47
121.204.253.48
121.204.253.49
121.204.253.50
121.204.253.51
121.204.253.52
121.204.253.53
121.204.253.54
121.204.253.55
121.204.253.56
121.204.253.57
121.204.253.58
121.204.253.59
121.204.253.60
121.204.253.61
121.204.253.62
121.204.253.63
121.204.253.64
121.204.253.65
121.204.253.66
121.204.253.67
121.204.253.68
121.204.253.69
121.204.253.70
121.204.253.71
121.204.253.72
121.204.253.73
121.204.253.74
121.204.253.75
121.204.253.76
121.204.253.77
121.204.253.78
121.204.253.79
121.204.253.80
121.204.253.81
121.204.253.82
121.204.253.83
121.204.253.84
121.204.253.85
121.204.253.86
121.204.253.87
121.204.253.88
121.204.253.89
121.204.253.90
121.204.253.91
121.204.253.92
121.204.253.93
121.204.253.94
121.204.253.95
121.204.253.96
121.204.253.97
121.204.253.98
121.204.253.99
121.204.253.100
121.204.253.101
121.204.253.102
121.204.253.103
121.204.253.104
121.204.253.105
121.204.253.106
121.204.253.107
121.204.253.108
121.204.253.109
121.204.253.110
121.204.253.111
121.204.253.112
121.204.253.113
121.204.253.114
121.204.253.115
121.204.253.116
121.204.253.117
121.204.253.118
121.204.253.119
121.204.253.120
121.204.253.121
121.204.253.122
121.204.253.123
121.204.253.124
121.204.253.125
121.204.253.126
121.204.253.127
121.204.253.128
121.204.253.129
121.204.253.130
121.204.253.131
121.204.253.132
121.204.253.133
121.204.253.134
121.204.253.135
121.204.253.136
121.204.253.137
121.204.253.138
121.204.253.139
121.204.253.140
121.204.253.141
121.204.253.142
121.204.253.143
121.204.253.144
121.204.253.145
121.204.253.146
121.204.253.147
121.204.253.148
121.204.253.149
121.204.253.150
121.204.253.151
121.204.253.152
121.204.253.153
121.204.253.154
121.204.253.155
121.204.253.156
121.204.253.157
121.204.253.158
121.204.253.159
121.204.253.160
121.204.253.161
121.204.253.162
121.204.253.163
121.204.253.164
121.204.253.165
121.204.253.166
121.204.253.167
121.204.253.168
121.204.253.169
121.204.253.170
121.204.253.171
121.204.253.172
121.204.253.173
121.204.253.174
121.204.253.175
121.204.253.176
121.204.253.177
121.204.253.178
121.204.253.179
121.204.253.180
121.204.253.181
121.204.253.182
121.204.253.183
121.204.253.184
121.204.253.185
121.204.253.186
121.204.253.187
121.204.253.188
121.204.253.189
121.204.253.190
121.204.253.191
121.204.253.192
121.204.253.193
121.204.253.194
121.204.253.195
121.204.253.196
121.204.253.197
121.204.253.198
121.204.253.199
121.204.253.200
121.204.253.201
121.204.253.202
121.204.253.203
121.204.253.204
121.204.253.205
121.204.253.206
121.204.253.207
121.204.253.208
121.204.253.209
121.204.253.210
121.204.253.211
121.204.253.212
121.204.253.213
121.204.253.214
121.204.253.215
121.204.253.216
121.204.253.217
121.204.253.218
121.204.253.219
121.204.253.220
121.204.253.221
121.204.253.222
121.204.253.223
121.204.253.224
121.204.253.225
121.204.253.226
121.204.253.227
121.204.253.228
121.204.253.229
121.204.253.230
121.204.253.231
121.204.253.232
121.204.253.233
121.204.253.234
121.204.253.235
121.204.253.236
121.204.253.237
121.204.253.238
121.204.253.239
121.204.253.240
121.204.253.241
121.204.253.242
121.204.253.243
121.204.253.244
121.204.253.245
121.204.253.246
121.204.253.247
121.204.253.248
121.204.253.249
121.204.253.250
121.204.253.251
121.204.253.252
121.204.253.253
121.204.253.254
121.204.253.255
121.204.253.256
121.204.253.257
121.204.253.258
121.204.253.259
121.204.253.260
121.204.253.261
121.204.253.262
121.204.253.263
121.204.253.264
121.204.253.265
121.204.253.266
121.204.253.267
121.204.253.268
121.204.253.269
121.204.253.270
121.204.253.271
121.204.253.272
121.204.253.273
121.204.253.274
121.204.253.275
121.204.253.276
121.204.253.277
121.204.253.278
121.204.253.279
121.204.253.280
121.204.253.281
121.204.253.282
121.204.253.283
121.204.253.284
121.204.253.285
121.204.253.286
121.204.253.287
121.204.253.288
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

论坛客服/商务合作/投诉举报:2171544 (QQ)
落伍者创建于2001/03/14,本站内容均为会员发表,并不代表落伍立场!
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论!
落伍官方微信:2030286 邮箱:(djfsys@gmail.com|tech@im286.com)
© 2001-2014

浙公网安备 33060302000191号

浙ICP备11034705号 BBS专项电子公告通信管[2010]226号

  落伍法律顾问: ITlaw-庄毅雄

手机版|找回帐号|不能发帖?|Archiver|落伍者

GMT+8, 2024-11-27 17:52 , Processed in 0.050034 second(s), 31 queries , Gzip On.

返回顶部