Menu

Ajax Form File Uploading

James Stortz

Uploading Files

asynchronous javascript and xml

Ajax

| OVERVIEW

Ajax file uploads should be simple and universal, on.js makes everything possible in one easy step.

| HIGHLIGHTS

  • Support for All Browsers
  • Progress/Event Support for Modern Browsers

| EVENTS

  • 'progress'
  • 'complete'
  • 'start'
  • 'end'
  • 'error'
  • 'abort'

| ALIASES

Upload Event(s)

('upload progress')[on](this)
(   function(e)
    {
        e.loaded;
        e.total;
        100 * (e.loaded/e.total) + "%";
    }
);

:::javascript
on.form.upload.progress.call
(   this
,   function(e)
    {
        e.loaded;
        e.total;
        100 * (e.loaded/e.total) + "%";
    }
);

:::javascript
('upload')[on](this)
(   function(e)
    {
        e.loaded;
        e.total;
        100 * (e.loaded/e.total) + "%";
    }
);

UPLOAD PROGRESS

<form id="TheUploadForm" action="../the/url">

<input type="file" value="Select A File" />

<input type="submit" value="Submit" />

</form>


:::javascript

('submit')[on](document.getElementById('TheUploadForm'))
(   function(e)
    {
        on.event.preventDefault.call(e);

        ('upload progress')[on](this)
        (   function(e)
            {
                e.loaded;
                e.total;
                100 * (e.loaded/e.total) + "%";
            }
        );

        ('POST')[on](this)
        (   function()
            {
                this.responseText;
            }
        );
    }
);

on.js

return true;

A JavaScript Library


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.