Solved

Create asp javascript page with file upload

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

707 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