0

i have been stressing for an hour at this stupid script i am trying to make it uploa an MP3 file to a folder it creates.

It is putting the information into mysql and making the folder bu when i ftp the folder is empty with no music file in there

here is the script thanks so so so much!

BTW $name is the POSTED name and full name is the posted name + ".mp3"

// BEGIN ENTERING INFORMATION TO MYSQL TABLE

$sql = mysql_query("INSERT INTO mattyc (name, date, length, size, link) 

     VALUES('$name','$date','$length','$size','$link')"
     )  or die (mysql_error());

   mkdir("../music/albums/donjuma/$name", 0777);

$song = ("../music/albums/donjuma/$name/$fullname");
        if (file_exists($song)) {
        unlink($song);
        }
        $newname = "$fullname";
        $newfile = rename(($_FILES['song']['tmp_name']),($newname));
        $place_file = move_uploaded_file( $newfile, "../music/albums/donjuma/$name/"."$newname");
        $success_msg = "<font color=\"#009900\">Your SONG has been updated, it may take a few minutes for the changes to show... please be patient.</font>";
        echo $success_msg;



    }
    }
}

1 Answer 1

1

$newfile = rename(($_FILES['song']['tmp_name']),($newname));
$place_file = move_uploaded_file( $newfile, "../music/albums/donjuma/$name/"."$newname");

rename() returns a bool, not a filename. So your move_uploaded_file() call is going to fail. Any file renaming should be part of your move_uploaded_file() call, don't try and do anything with your temporary file apart from move it.

Sign up to request clarification or add additional context in comments.

1 Comment

its people like you that make this site worth visiting.Thanks it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.