32 private links
The introduction of AJAX marked a huge leap forward in the history of the web. The ability to communicate with a web server without reloading the page has revolutionised how web applications are built. The primary technology that enables AJAX (XMLHttpRequests) has evolved significantly since the initial conception of dynamic websites.
A nice feature added to XMLHttpRequests in recent years is the ability to handle file uploads. Traditionally many developers have resorted to using technologies like Flash to upload files to a server. The problem with this approach is that the user needs to have a third-party browser plugin installed.
In this post you’ll learn how to upload files to a server using native JavaScript technologies. The example we’re going to use supports uploading multiple files in a single request. However, you can apply the same principles to single-file uploads too.
Uploading files has been done since the ice age of web development. In fact uploading a file using Html4 and an iFrame is pretty easy and does not even require a page refresh and about 0 line of code on the front-end, obviously you won’t get a progress bar but does it really matter?
File Upload widget with multiple file selection, drag&drop support, progress bars and preview images for jQuery.
Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.
Honesty hour confession: file uploading within the web browser sucks. It just does. Like the ugly SELECT element, the file input is almost unstylable and looks different on different platforms. Add to those criticism the fact that we're all used to drag and drop operations, yet up until recently, you couldn't drag files into a browser to upload them, making file uploading within the browser unintuitive. With recent advancements in browser technology, the drag and drop method is not supported, but it doesn't look good without a bit of work. Luckily MooTools Core Developer Arian Stolwijk has created a set of classes to accommodate styling drag and drop file uploading within the browser. Let's have a look at how it works!
Z serii ciekawe pluginy jQuery mam dzisiaj dla was jQuery File Upload. Oprócz standardowego uploadowania plików mamy możliwość skorzystania z paska postępu, a dodane już pliki możemy bez problemu usunąć. Do listy możliwości oferowanych przez plugin można również zaliczyć:
obsługa drag and drop
możliwość przerwania uploadu pliku
niewymagany Flash. Wszystko oparte o HTML5 i JavaScript
możliwość uploadowania plików do innej domeny
Do poprawnego działania plugin wymaga jQuery w wersji 1.4 oraz jQuery UI 1.8. Teoretycznie plugin działa w każdej przeglądarce (nawet IE6), w praktyce niektóre funkcjonalności w zależności od przeglądarki są okrojone.