How to Upload Attachments With AJAX
The Ajax language lets you upload a file from your user's desktop computer to the site without reloading the page after the file uploads. You use this method when you create an email solution and you want the user to send you a file. The Ajax language looks similar to JavaScript, so the code to upload is the same syntax, except the user's browser does not refresh.
Instructions
-
-
1
Right-click the HTML file you want to use to upload the file. Click "Open With" and select your preferred HTML editor.
-
2
Add the HTML element that your users use to submit the form and upload the file to the server. The following code adds an upload element to the page:
<input name="form[file]" type="file" />
-
-
3
Grab the file selected by the user and start the upload process. The following code uploads the file from the user's desktop:
AIM.form(f, AIM.frame(c));
c.onStart(); -
4
Display a completion message to the user when the file finishes uploading. The following code displays after the file uploads, so the user knows the process is complete:
if (c && typeof(c.onComplete) == 'function') {
i.onComplete = c.onComplete;
document.write("File upload completed");
}
-
1