Solved

How to do an AJAX file upload in ASP?

Posted on 2011-09-16
6
307 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

16 Experts available now in Live!

Get 1:1 Help Now