Solved

How to do an AJAX file upload in ASP?

Posted on 2011-09-16
6
309 Views
Last Modified: 2012-05-12
Hi Experts,
I've always coded file uploads using FreeAspUpload in a separate popup window, but would like to explore using Ajax instead.

Is this even possible? I've seen ajax upload tools but they're all ASP.NET and I'm looking for just pure ASP.

I've versed in Ajax and JQuery.
0
Comment
Question by:rascal
  • 3
  • 3
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36552703
do you have the server side code?
0
 
LVL 1

Author Comment

by:rascal
ID: 36552710
Yes, I have the server side ASP code - it is FreeAspUpload. (see attached and rename to .asp) freeASPUpload.txt
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36552734
OK, your answers are here, click on the examples and on the File uploads tab : http://jquery.malsup.com/form/#file-upload

so basically to post a form using the plugin, here a basic page  :
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script>
<script type="text/javascript" src="jquery.form.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
         $('#uploadForm').ajaxForm({ "success": function() { alert("file successfully uploaded !"); } });
    });
</script>
</head>
<body>
<form id="uploadForm" action="files.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Submit">
</form>
</body>
</html>

Open in new window

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:rascal
ID: 36552743
Thanks, but your solution is PHP based (see the action=files.php in your example) which our web server doesn't support. We need a completely 100% ASP solution.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36552748
You said you've the server side code. Don't be afraid by an extension (file.php)
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script>
<script type="text/javascript" src="jquery.form.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
         $('#uploadForm').ajaxForm({ "success": function() { alert("file successfully uploaded !"); } });
    });
</script>
</head>
<body>
<form id="uploadForm" action="files.asp" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Submit">
</form>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:rascal
ID: 36552777
Great, thanks leakim!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There is basically two types of AJAX request in mootools. Request  and Request.HTML Request: Request is the basic XHR request class in MooTools. While not extremely useful on its own, it provides the basic functionality for both Request.HTM…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

789 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