get a variable from javascript and use it in php
I want that when the user clicks an image a pop up window shows up asking
the user to input a name, in this case I want to create a folder in a
directory therefore the user has to input the name of the new folder to be
created.
Now to create the pop up I need to use javascript and to create the folder
I need to use PHP (server side). I am using the following code:
When the user clicks the image:
<div>
<a id="myLink" onclick="MyFunction();">
<img src="images/create_folder.png" width="60px" alt="create folder"/>
</a>
</div>
The code I am using to execute this operation:
<script>
function MyFunction(){
var foldername = prompt('Enter Folder Name');
<?php
$foldername = $_GET['foldername'];
mkdir('users_page/folders/', true);
?>
}
</script>
The pop up window I showing however when I click the ok button the folder
is not being created.
Can any one please help.
Thanks!
No comments:
Post a Comment