Solved

Create asp javascript page with file upload

Posted on 2011-09-23
3
271 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
ID: 36587586
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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 37233346
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

713 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