hi all,
i had done upload page in which we can upload files. But wat i need now is when we upload a file, that file should get saved into that persons folder and project name. wat i exactly mean is, wen 'X' logins and selects a project and uploads a file. Then it should check that if that person is having folder or not.if yes it should check that project is having a folder or not. If yes then it should save there. if not it should create folder with username and in that a folder with projectname. so any one can...
Thank u.
<?php
ob_start();
@session_start();
require_once ("check.php");
$con=mysql_connect("10.70.2.137","invensis","invensis");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database_myproject",$con);
$id=$_POST[fileid];
echo $id;
$filename=$_FILES['uploaded']['name'];
$s=($_FILES['uploaded']['size']);
$a= round($s/1024,2);
$size=round($s/1024,2)." kb";
$answer=$_SESSION[answer];
$usedmemory=$_POST['usedmemory'];
$allocatedmemory=$_POST['data1'];
$remainingmemory=$_SESSION['data3'];
if($a < $remainingmemory)
{
$sql="insert into files(filename,size,uploadedby,projectname) values ('$filename','$size','$_SESSION[username]','$_SESSION[answer]')";
mysql_error();
$result = mysql_query($sql);
$dirname=$_POST['projectname'];
$dir="files";
if(is_dir($dirname))
{
$target = "$dir/$dirname/";
$target = $target . basename( $_FILES['uploaded']['name']);
$ok=1;
if ($ok==0)
{
echo "Sorry your file was not uploaded";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo " ";
}
}
}
else
{
$path="$dir//$dirname";
@mkdir($path,0777,true);
$target = "$dir/$dirname/";
$target = $target . basename( $_FILES['uploaded']['name']);
$ok=1;
if ($ok==0)
{
echo "Sorry your file was not uploaded";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo " ";
}
}
}
}
else
{
echo "<strong style='color:#FF3333'>"."<left><h1>Insufficient Memory.</h1></left>"."</strong>";
}
?>