Re: Adding a progress bar to image and document uploads

  •  05-20-2004, 7:43 AM

    Re: Adding a progress bar to image and document uploads

    There are 2 change si made to the code

     

    taken from upload.asp (renamed upload2.asp to save original code)

    ***************************************************

    <html>
     <head>
      <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      <title>Upload Page</title>
     </head>

    <%
    Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
    PID = "PID=" & UploadProgress.CreateProgressID()
    barref = "framebar.asp?to=10&" & PID
    %>

    <SCRIPT LANGUAGE="JavaScript">
    function ShowProgress()
    {
      strAppVersion = navigator.appVersion;
      if (document.f.uploadimage.value != "")
      {
     if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
     {
       winstyle = "dialogWidth=375px; dialogHeight:130px; center:yes";
       window.showModelessDialog('<% = barref %>&b=IE',null,winstyle);
     }
     else
     {
       window.open('<% = barref %>&b=NN','','width=370,height=115', true);
     }
      }
      return true;
    }
    </SCRIPT>

     <body bgcolor="buttonface">
     <%
      Dim ImageGalleryPath,MaxImageSize
      ImageGalleryPath = Request.QueryString("GP")
      MaxImageSize = Request.QueryString("MaxImageSize")
     %>

      <form action="filePost2.asp?GP=<%=ImageGalleryPath%>&MaxImageSize=<%=MaxImageSize%>&<%=PID %>" enctype="multipart/form-data" method="post" name="f" id="f" OnSubmit="return ShowProgress();">
       <table border="0" style="font-family: MS Sans Serif; font-size: 9pt; vertical-align: top;" cellspacing="2" cellpadding="0" width="100%" align="center" ID="Table1">
        <tr>
         <td>
          <input type="file" name="uploadimage" size="25" maxlength="50" />
         </td>
        </tr>
        <tr>
         <td>
          &nbsp;&nbsp;<input type="submit" value="Upload" />
         </td>
        </tr>
       </table>
      </form>
     </body>
    </html>

     

    ***************************************************

    taken from filepost.asp (renamed filepost2.asp to save original code)

     

    ***************************************************

    <%
    Dim Count
    Dim Upload
    Dim strfilepath
    Dim File
    Dim ImageGalleryPath
    Dim MaxImageSize

     On Error Resume Next
     Server.Scripttimeout = 20000
     errMsg = ""

     ImageGalleryPath = Server.MapPath(Request.QueryString("GP"))
     MaxImageSize = (Request.QueryString("MaxImageSize")*1024)

     Set Upload = Server.CreateObject("Persits.Upload")
     Upload.ProgressID = Request.QueryString("PID")
     strfilepath = filePath
     Upload.OverwriteFiles = False
     Count = Upload.Save(ImageGalleryPath)

     If Err.Number = 8 Then
      errMsg = "<font color=red><b>Your file is too large. Please try again.</b></font>"
     Else
      For Each File in Upload.Files
       strFile = File.ExtractFileName

       Select Case File.ImageType
        Case "GIF","JPG"
        Case Else
         errMsg = "<font color=red><b>File format not supported! - Supported Files (JPG,GIF)</b></font>"
         File.CopyVirtual ImageGalleryPath & File.FileName
         File.Delete
         Exit For
       End Select
      Next
     End If
    %>

    <html>
    <head>
     <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </head>
    <body bgcolor="buttonface" style="font-family: MS Sans Serif; font-size: 9pt; vertical-align: top;">
    <%
     if errMsg = "" then
      Response.Write strFile &" uploaded successfully!"%>
      <script>parent.frames['browse_Img'].Editor_upfolder('browse_Img');</script>
    <% else
      Response.Write errMsg
     end if
    %>
     <br><br>
     <a style="font-family: MS Sans Serif; font-size: 9pt; vertical-align: top; cursor: hand;" href="upload.asp?GP=<%=ImageGalleryPath%>&MaxImageSize=<%=MaxImageSize%>">Upload again</a>
    </body>
    </html>
    ****************************************************

    Any questions just shout

View Complete Thread