Hello everyone,

Here's my problem:
I need to be able to upload some info about an mp3 to a database (name,
filename, size, and file_type).  I can do this already, and it works just
fine.  After the info is added to the database, the mp3 is uploaded to
music/$binFile_name.

Here's the code I have to put info into the db and upload the file to the
music directory:
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
    $strDescription = addslashes(nl2br($txtDescription));
    $album_sql = mysql_query("SELECT *  FROM albums WHERE id = '$album_id'
AND artist_id = '$artist_id'");
    $album = mysql_fetch_object($album_sql);
    $sql = "INSERT INTO music
    (artist_id, artist, album_id, album_title, track_name, track_number,
mp3_type, description, filename, filesize, filetype) VALUES ('$artist_id',
'$artist', '$album_id', '$album->album_title', '$track_name',
'$track_number', '$mp3_type', '$strDescription', '$binFile_name',
'$binFile_size', '$binFile_type')";
    $result = mysql_query($sql, $db);
    mysql_free_result($result);
    $len = strlen($data);
    if ($fp = fopen("../../music/$binFile_name", "wb")) {
        if ($size = fwrite($fp, $data, $len)) {
                print "<font face=Arial size=2>Thanks, $binFile_name has been added to
our database.</font>";
                fclose ($fp);
        }
        else {
                print "<font face=Arial size=2>$binFile_name couldn't be written to,
perhaps some permissions are wrong?";
        }
    }
    else {
        print "<font face=Arial size=2>$binFile_name couldn't be opened (or
created), please try again.</font>";
    }


One problem begins when trying to play that MP3.  When I try to play the
MP3, it NEVER plays.  Is there some headers that need to be sent while
uploading the file?

Here's the code I use to let users download the mp3:
while ($row = mysql_fetch_array($sql)) {
        $artist = $row["artist"];
        $artist_id = $row["artist_id"];
        $id = $row["id"];
        $track_name = $row["track_name"];
        $type = $row["mp3_type"];
        $filename = $row["filename"];
        if ($alternate == "1") {
                $color = "#ffffff";
                $alternate = "2";
        }
        else {
                $color = "$color1";
                $alternate = "1";
        }
        print "<tr bgcolor=$color><td width=33%><a
href=bands.php?option=View%20Band&id=$artist_id><font face=Arial size=2
color=#000000>$artist</font></a></td><td width=33%><A
href='music/$filename'><font face=Arial size=2
color=#000000>$track_name</font></a></td><td width=34%>$type</td></tr>";
}

So the final dl link ends up being: <a href='music/filename.mp3'>Track
Name</a>
I can download this in IE, but it still won't play, and when I do a "Save
Target As" the file name is all screwed up.
If the link was this: <a href="http://localhost/sweetleaf/music/Provoke -
Quick Blast.mp3>Quick Blast</a> you'd think the filename I'd download would
be "Provoke - Quick Blast.mp3".  When doing a Save Link As, this is the
filename: ProvokQuicBlast.mp3.  Any ideas why?

Also, when downloading in NS, I get this: The parameter is incorrect.
Any idea what that means?

thanks for sitting through all of this.  I hope you can offer me some help.
:)

Regards,
Tyler Longren

P.S.
If you'd like more of my code to look @, just let me know.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to