Create New Folder With PHP
Posted: Mon Sep 04, 2006 10:48 pm
ok so i have an existing and working file upload script, but i want to be able to, in the HTML doc where you select the file to upload, be able to either select an existing folder to upload to, OR create a new folder, and then be able to upload to the newly created folder.
here is my existing PHP:
and here is my existing HTML:
here is my existing PHP:
Code: Select all
<?php
$bad_types = array('application/octet-stream','application/x-msdos-program','application/x');
if( in_array( $_FILES['uploadedfile']['type'], $bad_types ) )
{
echo "That File type is not supported.";
}
else
{
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded. here is the link to your file: <a href=uploads/". basename( $_FILES['uploadedfile']['name']). ">". basename( $_FILES['uploadedfile']['name'])."</a>";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>Code: Select all
<body>
<form method='post' action='upload.php' enctype='multipart/form-data'>
<input type='file' name='uploadedfile' /><br />
<input type='submit' value='Upload File' />
</form>
</body>