Hi, I cannot fathom for the life of me what is wrong with my code. In any case, I believe the ajax code is right (I could be wrong though).

I have a "form" which is one field long and which I don't care about submitting. I need to use the CURRENT typed in value, so that I can send it over to another page without submitting any values and thus changing page - hence the use of ajax. I have a fake submit button (created by divs) which is outside of the form. I will use that one to submit the content along with the folder name.

On the second page, which is an upload page, I am trying to create a folder. Basically, in my images folder, I want to create ONE subfolder only. So in my form, the person types in a name in the text box, and then that value is going to become the name of the new folder.

I looked on the net concerning something called folder recursion. Someone suggested something about that (but I had misunderstood his suggestion). Anyhow, I have looked online for that to begin with, but without any luck. As I need to use typed in values, what I found online does not help me in that regards.

The best I can output is $folder which is created in my images directory. In any case, since that attempt has failed, I have reworked my coding several times. But the following is the best I can come up with.

Here is my coding:


HTML Code:
<!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    
    <title>File Upload!</title>
    <script src="jquery.js"></script>
    <script src="javascript.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="stylesheet" type="text/css" href="pacifico.css" />
    
    
    </head>
    <body>
    
    <script>
    setInterval(function(){
         $.post("test.php",{
                value: $("#folder").val()
            }, 
            function(result){
                console.log('saved!');
          });
    }, 2000);
    </script>
    
    
        <div>
        <form>
        	<input type="text" id="folder" name="folder">
            <input id="btn_send" type="button" value="Submit" />
         </form>
        </div>
      
    <div class="content">
    	<div id="drop-files" ondragover="return false">
    		Drop Images Here
    	</div>
    	
    	<div id="uploaded-holder">
    		<div id="dropped-files">
    			<div id="upload-button">
    				<a href="#" class="upload">Upload!</a>
    				<a href="#" class="delete">delete</a>
    				<span>0 Files</span>
    			</div>
    		</div>
    		<div id="extra-files">
    			<div class="number">
    				0
    			</div>
    			<div id="file-list">
    				<ul></ul>
    			</div>
    		</div>
    	</div>
    	
    	<div id="loading">
    		<div id="loading-bar">
    			<div class="loading-color"> </div>
    		</div>
    		<div id="loading-content">Uploading file.jpg</div>
    	</div>
    	
    	<div id="file-name-holder">
    		<ul id="uploaded-files">
    			<h1>Uploaded Files</h1>
    		</ul>
    	</div>
    </div>
    </body>
    </html>
and the other page


PHP Code:
 <?php
    
    $folder 
$_GET['folder'] . '/';
    
    
    
$dirPath $folder;
    
    
$result mkdir($dirPath0755);
    if (
$result == 1) {
        echo 
$dirPath " has been created";
    } else {
        echo 
$dirPath " has NOT been created";
    }
    
    
    
// We're putting all our files in a directory called images.
    
$uploaddir 'images/'.'$folder';
    
    
// The posted data, for reference
    
$file $_POST['value'];
    
$name $_POST['name'];
    
    
// Get the mime
    
$getMime explode('.'$name);
    
$mime end($getMime);
    
    
// Separate out the data
    
$data explode(','$file);
    
    
// Encode it correctly
    
$encodedData str_replace(' ','+',$data[1]);
    
$decodedData base64_decode($encodedData);
    
    
    if(
file_put_contents($uploaddir.$folder.$name$decodedData)) {
    ;
    }
    else {
        
// Show an error message should something go wrong.
        
echo "Something went wrong. Check that the file isn't corrupted";
    }
    
    
?>