How to upload image with NicEdit and classic asp


Staff member
I would like to use
image upload with classic asp. By default Nicedit uploads images to ImageShack, but I would like to send images to my server. However I'm having trouble to adapt some features of the original PHP script to classic asp. I found <a href="" rel="nofollow">this script</a> that uploads the image and returns the image info in javascript format and generates a progress bar.

    catch(e) {

PHP has built-in functions that provide a progress bar and I have difficulties setting up a progress bar in vbscript.

Could someone guide me on what should be implemented so that the basic functions of this script remain in the asp version? Thanks.


I made the upload script that is working well, but I need help to make the progress bar. I usually use the <a href="" rel="nofollow">jQuery progress bar inside a loop</a> but would like to help in order to make it work during this upload process.

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