Click here to Skip to main content
12,823,976 members (41,120 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 11 Oct 2013

Creating and Deleting Files on Fly on WebServer through Javascript (Magic of HTML and Jquery)

, 11 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Creating and Deleting Files on Fly on WebServer through Javascript (Magic of HTML and Jquery)We usually know the methods of POST and GET for posting

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Creating and Deleting Files on Fly on WebServer through Javascript (Magic of HTML and Jquery)

We usually know the methods of POST and GET for posting and fetching data from WebServer.

There are many other HTML verbs used . Two of them are PUT and DELETE

PUT - used for moving,updating creating files through WEBDAV on webserver.

DELETE - used for deleting file through WEBDAV on webserver

WEBDAV - Web distributed Versioning and Authoring originally developer by IEE and accepted by HTML community as a standard for various Webserver functioning.


As though it is not easy to create a request for PUT and DELETE as it contains raw html and do not use forms.

but through JQUERY we can acheive this in a much simple way.


1) jquery has ajax function which helps in creating ajax requests asynchronously

2) we can setup this call this ajax function for creating a file on webserver.

$.ajax( {data:'MyTestData', type:'PUT', url:'http://localhost/TestWeb/TestFile.txt' } )

Here we are setting up ajax request for PUT verb which will create a file TestFile.txt on TestWeb Folder with data

'MyTestData' written into it.

If we want to insert some heavy data into this file we can also use like this

$.get('http://localhost/TestWeb/Default.aspx' , null, function(testdata) {

 $.ajax( {data:testdata, type:'PUT', url:'http://localhost/TestWeb/TestFile.txt' } )

}, null);

 Here we have requested data for page Default.aspx which will return HTML code for page through ajax.

function(testdata) is function which get called when ajax request has been successfully completed with the testdata as return value from response.

We can then pass this testData to our previous method which will create file testFile.txt on server and insert the data into this file.

 Same way we can also do for DELETE

 $.ajax( { type:'DELETE', url:'http://localhost/TestWeb/TestFile.txt' } )

Here we dont use data option as we only want to delete the file from server.


So in a way we can create files and delete them on fly just by using simple jquery and knowledge of HTML verbs.






This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

768 members

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid