Solved

Create asp javascript page with file upload

Posted on 2011-09-23
3
264 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 142

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

770 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