本人phper,但负责asp项目迁移,太多不懂,求指教。我的asp项目从win2003迁移到win2008r2后发现图片等文件不能上传,我的考虑和处理如下:
1.之前老服务器都是正常的,程序方面应该没有问题(不是我写的)。
2.安装上传和图片处理组件 aspupload,aspjpeg
3.给文件夹给权限IUSR,everyone都给了完全控制
4.它的上传用的是uploadify插件版本2.11
脚本upload.asp大概如下:
rootFolderPath = "/files/" '上传文件路径
set upload=new UpLoadClass '配置参数
upload.MaxSize= 40960000 '上传文件大小
upload.FileType="gif/jpg/png/bmp/jpeg/tiff/flv/3gp/avi/rm/wmv/mkv/doc/docx/ppt/pptx/xls/xlsx/pdf/rar/zip/ai" '文件类型
upload.AutoSave=2
upload.Open()
'获取表单数据
Rename = upload.form("Rename")
Zoom = upload.form("Zoom")
'table_name=upload.form("table_name")
'判断文件是否存在
Public Function IsFileExist(filepath)
Dim fs
Set fs = CreateObject("Scripting.FileSystemObjectj")
If fs.FileExists(filepath) Then
IsFileExist = True
Else
IsFileExist = False
End If
Set fs = Nothing
End Function
'文件重命名
Public Function GetTimeFileName(FileName)
Dim Nows, FileExtendName
FileExtendName = Right(FileName, Len(FileName) - InStrRev(FileName, ".", -1, 1))
Randomize
Nows = Now()
GetTimeFileName = Year(Nows) & right("0" & Month(Nows), 2) & right("0" & Day(Nows), 2) & right("0" & Hour(Nows), 2) & right("0" & Minute(Nows), 2) & right("0" & Second(Nows), 2) & Int(900 * Rnd + 100) & "." & FileExtendName
End Function
'缩略图命名
public Function ZoomFileName(FileName,width,height)
Dim FileExtendName,strFileName
FileExtendName = Right(FileName, Len(FileName) - InStrRev(FileName, ".", -1, 1))
strFileName = replace(FileName,"."&FileExtendName,"")
ZoomFileName = strFileName & "-" & width & "-"& height & "." & FileExtendName
End Function
'文件重命名 在文件后面加1
Public Function RenameFileName(path,FileName)
Dim FileExtendName,strFileName
FileExtendName = Right(FileName, Len(FileName) - InStrRev(FileName, ".", -1, 1))
strFileName = replace(FileName,"."&FileExtendName,"")
Dim iCounter
iCounter = 0
Do While (true)
If (IsFileExist(server.MapPath(path&FileName))) Then
iCounter = iCounter + 1
'RenameFileName = strFileName & "(" & iCounter & ")." & FileExtendName
RenameFileName = RemoveExtension( strFileName ) & "(" & iCounter & ")." & FileExtendName
response.Write RenameFileName
Else
RenameFileName = FileName
Exit Do
End If
Loop
End Function
Function RemoveExtension( fileName )
RemoveExtension = Left( fileName, InStrRev( fileName, "." ) - 1 )
End Function
if Rename = "true" then
filename = GetTimeFileName(upload.form("Filedata_name"))
end if
' 2011-09-13
'判断文件类型 split_type(数组,要判断的文件的类型)
Public function split_type (format,type_name)
Dim formatubound
formatubound=split(format,",")
for i=0 to ubound(formatubound)
if type_name=trim(formatubound(i)) then
split_type=true
exit for
else
split_type=false
end if
next
end function
Function CreateFolder(FolderPath)
' On Error Resume Next
Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
Set F=Fso.CreateFolder(Server.MapPath(FolderPath))
CreateFolder=F.Path
Set F=Nothing
Set Fso=Nothing
' Select Case Err
' Case 424 Response.Write("方卡错误提示:创建"&FolderPath&"文件夹时,路径未找到或者该目录没有写入权限!")
' End Select
End Function
Nows = Now()
TimeFolderName = Year(Nows) & "-" & right("0" & Month(Nows), 2) & "-" & right("0" & Day(Nows), 2) & "/"
'修改 分类保存上传文件
path = rootFolderPath
oldpath = rootFolderPath
'file_type = Right(fileItem.FileName, Len(fileItem.FileName) - InStrRev(fileItem.FileName, ".", -1, 1)) '获取文件类型
file_type = upload.form("Filedata_Ext")
'设置图片上传目录
image_upload="gif,jpg,png,bmp,jpeg,tiff" '上传图片文件格式
type_image = split_type (image_upload,file_type)
if type_image then
path = path & "images/" & TimeFolderName
else
path = path
end if
'设置视频上传目录
video_upload="flv,3gp,avi,rm,wmv,mkv" '上传图片文件格式
type_video = split_type (video_upload,file_type)
if type_video then
path = path & "video/" & TimeFolderName
else
path = path
end if
'设置办公文件上传目录
office_upload="doc,docx,ppt,pptx,xls,xlsx,pdf,rar,zip" '上传图片文件格式
type_office = split_type (office_upload,file_type)
if type_office then
path = path & "office/" & TimeFolderName
else
path = path
end if
'设置其他目录
if oldpath = path then
path = path & "other/" & TimeFolderName
else
path = path
end if
'创建文件夹
if dp.NoFolder(server.MapPath(path)) then CreateFolder(path)
'文件按原名称保存
if Rename = "false" then
filename = RenameFileName(path,upload.form("Filedata_name"))
end if
'上传文件
upfilepath=path&filename
upload.save "Filedata", upfilepath
'图片等比缩
if Zoom = "true" then
width = upload.form("width")
height = upload.form("height")
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(upfilepath)
Jpeg=AutoSizeJpeg(width,height,Jpeg)
ZoomName = path&ZoomFileName(filename,width,height)
Jpeg.Save Server.MapPath(ZoomName)
Set Jpeg = nothing
end if
'输出文件路径
if upload.Error=0 then
if Zoom = "true" then
response.Write upfilepath&"|1"&ZoomName
'response.Write upfilepath
else
response.Write upfilepath
end if
else
response.Write -1
end if
set upload=nothing
返回结果是 "/files/other/2015-11-02/",而且2015-11-02文件夹也没有创建成功。权限都是有的。作为phper的我只能求指教了。谢谢各位。
IIS 上 200K
的限制改大了没?如果没有的话,打开IIS,再点你的站点,然后双击 ASP
进去,最下面有一个 限制属性
,把前面的加号点开,就会看到有一个 最大请求实体主体限制
,默认是200K,改成为 20M (默认值后面再加两个0)试下。