?
Solved

Create asp javascript page with file upload

Posted on 2011-09-23
3
Medium Priority
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 2000 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

Independent Software Vendors: 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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 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