Solved

How to do an AJAX file upload in ASP?

Posted on 2011-09-16
6
306 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Hello World !, Thanks : My Sincere thanks to @Michael Male who encouraged me to write an article on this in my  blog (http://scribblejava.wordpress.com). Introduction:       There are several technical issues a developer may face in his…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now