create folder / subfolder on the fly to store files
Posted: Fri Aug 19, 2011 7:19 pm
here is my code so far
where you see 'term and 'term2' are from user inputs. the concept is to have the files uploaded to folders with the terms the user states, which may not be created yet, but if they are i dont want to create them, just check to see if the file, then, has been uploaded to that location, etc
any ideas are welcome
Code: Select all
<?php
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = mysql_real_escape_string($_POST['term']);
$term2 = mysql_real_escape_string($_POST['term2']);
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
//echo "Upload: " . $_FILES["file"]["name"] . "<br />";
//echo "Type: " . $_FILES["file"]["type"] . "<br />";
//echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
//echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("efiles/" . $term . "/" . $term2 . "/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"efiles/" . $term . "/" . $_FILES["file"]["name"]);
//echo "Stored in: " . "efiles/" . $_FILES["file"]["name"];
}
}
echo $term;
?>
<html><body>
<script type="text/javascript">
</script>
</body></html>
where you see 'term and 'term2' are from user inputs. the concept is to have the files uploaded to folders with the terms the user states, which may not be created yet, but if they are i dont want to create them, just check to see if the file, then, has been uploaded to that location, etc
any ideas are welcome