Code:
//check for directories
if (is_dir("music")){
if (is_dir("music/users")){
if (is_dir($fileUrl)){
if(move_uploaded_file($fileTempLocation, "music/users/".$_SESSION['logged_in_user']."/".$fileName)){
//add to database
if (isset($mysqli)){
//connection is made to mysql server $mysqli as an object
if($preStmtIn = $mysqli->prepare("INSERT INTO artist_songs(id, uid, band, song, album, size, url, imgUrl) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")){
$preStmtIn->bind_param("ssssssss", $fileId, $_SESSION['uid'], $_SESSION['abName'], $fileName, $albumName, $fileSize, $fileUrl, $imgUrl);
$inserted = $preStmtIn->execute();
//insert to artist_songs completed
if($inserted){
if($preStmt = $mysqli->prepare("SELECT id, uid, song, album, size, url, imgUrl FROM artist_songs WHERE uid=?")){
$preStmt->bind_param("s", $_SESSION['uid']);
$preStmt->execute();
$preStmt->bind_result($id,$uid,$song,$album,$size,$url,$imgUrl);
while($preStmt->fetch()){
printf("<b>id:</b> %s <b>uid:</b> %s <b>Song:</b> %s <b>Album:</b> %s <b>Size:</b> %s <b>url:</b> %s <b>Album cover:</b> %s<br/>", $id, $uid, $song, $album, $size, $url, $imgUrl);
}
}
}else{
echo "Error:" . mysqli_error($mysqli);
}
}else{
echo "Could not prepare statment!";
}
}else {
echo "mysqli is not connected: " . mysqli_error($mysqli);
}
}else{
print "Error: file was not able to be moved;";
}
}else{
mkdir("music/users/".$_SESSION['logged_in_user']);
}
}else{
mkdir("music/users");
}
}else{
mkdir("music");
}
This checks for directories then moves the uploaded file to the users allocated files folder. It then will check for MySQLi connection and try to insert information to the database. Then it simply echos out the users data.
It works OK yet slow. I am not sure if its the code here but this is what caught my eye as I was looking through the code tonight.
Any wisdom would be appreciated.

New Topic/Question
Reply



MultiQuote




|