Solved

Create asp javascript page with file upload

Posted on 2011-09-23
3
251 Views
Last Modified: 2012-05-12
Would like to create a simple javascript asp web form with ability to upload multiple files of various types.  Anything from .pdf to .jpeg to .tif

Does anyone have a sample script that would do this??  
0
Comment
Question by:JWHomes
3 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
Comment Utility
A bit too general but you can use this.

All you would need to do is go to http://www.persits.com to download a component an upload component.

first page is called uploadfile.asp or whatever you wish to call it.

            <FORM METHOD="POST" NAME="myform" ENCTYPE="multipart/form-data" ACTION="processUpload.asp">
            <table width="540" border="0" cellspacing="2" cellpadding="2">
              <tr valign=top>
                <td class="body1"><div align="right">File Title</div></td>
                <td><input name="ftitle" type="text" CLASS="ilong" size="48"></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">File Description</div></td>
                <td><input name="briefDescr" type="text" size="48"></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">File Name</div></td>
                <td><input name="filename" type="text" size="48"></td>
              </tr>
              <tr valign=top>
                   <TD align="right" CLASS="standardtext" width="0%" valign="top" nowrap><div style="padding-top: 3px">Attachment</div></TD>
                   <TD id="xattachement"><INPUT NAME="writeattach[]" TYPE="FILE" value="" SIZE=40 style="width: 85%"><br>
                     <div id="xattachement1"></div>
                   </TD>
              </tr>
              <tr valign=top>
                <td class="body1" div align="right">Path</td>
                <td> <select name="FilePath" style="font-family: Verdana; font-size: 8pt; color:#FF0000">
                      <option value="FirstFolder">Save to first folder</option>
                      <option value="SecondFolder">Save to 2nd folder</option>
                    </select><br>
                </td>
              </tr>
              <tr valign=top>
                <td class="body1"><img src="images/layout/spacer.gif" height="10" width="1"></td>
                <td></td>
              </tr>
              <tr valign=top>
             <td class="body1">&nbsp;</td>
             <td><input type=button name='Submit' value='Upload file' class='button' onClick="{document.myform.submit();}"></td>
            </tr>
           </table>

Open in new window


second page is called processUpload.asp or whatever you wish to call it.

     <HTML>
       <BODY>
        <%
          Set Upload = Server.CreateObject("Persits.Upload")
          ' we use memory uploads, so we must limit file size
          Upload.SetMaxSize 1000000, False
          Upload.IgnoreNoPost = True
          ' Save to memory. Path parameter is omitted
          Upload.Save

          ' Access subdirectory specified by user
          filePath = Upload.Form("filePath")

          ' Build path string
          Path = "C:\FolderName\" & filePath '***Change to your actual path/folder name
          'response.write Path
          'response.end

          ' Create path, ignore "already exists" error
          Upload.CreateDirectory Path, True

          ' Save files to it. Our form has only one file item
          ' but this code is generic.
          For Each File in Upload.Files

           File.SaveAs Path & "\" & File.FileName

'***Use below if inserted title to the db
Dim conn, rs, sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=" & server.mappath("../database/yourDB.mdb")
conn.Open
SQL = "INSERT INTO uploads (fTitle, filename, whenuploaded) " _
       & " VALUES('" & filePath & "','" & File.FileName & "', Now() )"
   conn.Execute SQL
   conn.Close

       Response.Redirect "uploadSuccess.asp" '*** create success page to redirect to if you wish to use it.

   Next
  %>
  </BODY>
 </HTML>

Open in new window


Good luck
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now