PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Ajax file upload with javascript validation

June2

Use ajax to upload files with javascript validation. Ajax is another word for fast and user friendly web pages.

I have retrieved the code to upload files using ajax from http://www.webtoolkit.info/ and added javascript validation along with it.

I will give a brief explanation below on the topic. Download the script from top of this webpage and set it on your local server with read and write permissions and then if you have any doubts let me know. Here goes…. this script contains three files

  1. email.php – html form
  2. send.php – server side coding
  3. webtoolkil.js – the actual functionality of iframes used in upload files through ajax

Download the three files from this webpage.

Brief Explanation

Ajax is used every where to make web navigation an easier experience, it mainly uses httpxmlrequest javascript object to serve its purpose. Click here to get the basics in ajax.

Now I want to upload files using ajax but that cannot be done from above mentioned method due to some security reasons. So we had to use hidden iframes for the same. This helps you to upload files and access other form elements on the same web page you don’t have to submit to another page saving time and patience.

But here I noticed that we had to loose javascript validation, as none of the scripts available online came with it. So I added validation through a function validate(), refer to the code in the downloaded files.

I know the explanation is hasty but once you get the files and look at the code carefully you will get it completely :)

posted under Ajax

Email will not be published

Website example

Your Comment:

 

12,829 spam comments
blocked by
Akismet