如何使用NicEdit和经典asp上传图像

时间:2011-12-09 13:25:53

标签: asp-classic vbscript nicedit

我想将nicedit图片上传与经典asp一起使用。默认情况下,Nicedit将图像上传到ImageShack,但我想将图像发送到我的服务器。但是我无法将原始PHP脚本的某些功能改编为经典的asp。我找到this script上传图片并以javascript格式返回图片信息并生成进度条。

<script>
    try{
        top.nicUploadButton.statusCb({'done':1,'url':'$link','width':30});
    }
    catch(e) {
        alert(e.message);
    }
</script>

PHP具有提供进度条的内置函数,我在vbscript中设置进度条时遇到了困难。

有人可以指导我应该实施什么,以便此脚本的基本功能保留在asp版本中?感谢。

== UPDATE ==

我使上传脚本运行良好,但我需要帮助来制作进度条。我通常会使用jQuery progress bar inside a loop,但希望在上传过程中提供帮助。

<%
Server.ScriptTimeout = 26000

UplMaxSize = 1048576
sExtL = "jpg,jpeg,png,gif,bmp"

Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = True
Upload.SetMaxSize UplMaxSize, True 
nCount = Upload.Save
If nCount > 0 Then
Set File  = Upload.Files(1)
sFileName = File.FileName
sWidth    = File.ImageWidth

If Err.Number = 8 Then
    Set uplresult = jsObject()
        uplresult("error") = "O tamanho do arquivo excedeu o limite!"
    uplresult.Flush ' estampa json
    Response.End()
End If

If Not File Is Nothing Then
    ' Save the file to the file system
    sPath = Server.MapPath(".\public\upimages")

    Set oFSO = Server.CreateObject("Scripting.FileSystemObject")

    sExt = oFSO.GetExtensionName(sPath & sFileName)
    If Not (InStr(sExtL,sExt) > 0) Then
        Set uplresult = jsObject()
            uplresult("error") = "Extensão de arquivo inválida!"
        uplresult.Flush ' estampa json
        Response.End()
    End If
    File.SaveAs sPath & "\" & sFileName
    Response.Write("<script>try  {top.nicUploadButton.statusCb({'done':1,'url':'/blog/public/upimages/" & sFileName & "','width':" & sWidth & "});} catch(e) {alert(e.message);}</script>")
End If
End If
%>

0 个答案:

没有答案