I'm trying to make a PHP script for mp3 uploads, But I want to make a folder on upload if one does not exists, using the user's session $_SESSION[username] in folder mp3/, when i run at the command line i get no error's but when i try to up load a mp3 it fails everytime ,and dose not make the folder .
<?php
session_start();
if (isset ($_SESSION ['band_id' ]))
{
$band_id = $_SESSION ['band_id' ];
$bandname = $_SESSION ['bandname' ];
$username = $_SESSION ['username' ];
}
// set database connection
require("connect.php");
// lets get our posts //
$song = $_FILES['song_name'];
// folder that will hold songs
$songpath = '/mp3/' . $_SESSION['username'];
// song-file pathname
$songpath .= $song['name'];
if (!file_exists($songpath)) {
mkdir($songpath."/".$_SESSION['username'], "/" ,0777,true);
}
var_dump($songpath);
// move the file from the tmp folder to the song folder
if (move_uploaded_file ($song['tmp_name'], $songpath))
{
print "<p>Upload succeeded thank you</p>
";
}
else
{
print "<p>Upload failed, sorry</p>
";
}
print <<<END
<p>
To continue, <a href="index.php">click here.</a>
</p>
</body>
</html>
END;
?>