0

i want to create a folder on the server using AJAX... and i am using the following codes....

function createFolder() {
    var encodedName = "bla bla bla"; //$.URLEncode(name);
    ajaxLoadingOn();
    $.ajax({
        type: 'POST',
        url: "_DAV/MKCOL",
        data: {
            name: encodedName
        },
        dataType: "json",
        success: function() {
            ajaxLoadingOff();
            window.location = encodedName + "/index.html";
        },
        error: function() {
            ajaxLoadingOff();
            alert('There was a problem creating the folder');
        }
    });
}

but it doesn't work is there a complete tutorial that i can follow to create a folder on the server using ajax... any help would be appreciated... :) thanks in advance.. :)

4
  • post your _DAV/MKCOL code also Commented Nov 24, 2013 at 8:24
  • Where is php code which creates folder? Commented Nov 24, 2013 at 8:25
  • i'm sorry i'm new to ajax... i don't know what php code to write... Commented Nov 24, 2013 at 8:28
  • which server side code are u using Commented Nov 24, 2013 at 8:31

1 Answer 1

2

You can't actually use AJAX by itself to create a folder on a server. The AJAX code can be used to talk to another type of code such as PHP, ASP, Python, etc (Any server side code flavor).

You should take a few things into account before considering doing this. If AJAX can see, interact, or just essentially use this code. So can I, or any other experienced web developer. You do not want to keep something like that so open. You should probably go about this in a different way. I would suggest your program/page with the AJAX on it, use some sort of self presence when passing information to the Python code (or whatever server side of your choice), and your Python program use its libraries to determine if it has the needed info, it was passed with the presence (such as the web URL location, and a bit of tracking to find out what the previous page actually is from a server side perspective. If the two locations match, and all the data is there, then you can process the creation of the folder.

However, dynamically creating folders is just a bad idea. You could have a leak or something and end up with a few million folders in a matter of moments. Or someone could find a way, cause there is always a way, and then a few million gets created for "fun". etc.

Long story short, do a quick google search for "create folder on server with PHP", and then "Use AJAX to call a PHP function" and you are ready to go.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.