Hello, I am trying to upload music files to a database for use on my website. However, the file doesn't seem to actually be going into the folder. I get the name of the file in phpmyadmin, but I don't see the file anywhere. Here's my script (I do have a directory in the database named music, so that doesn't seem to be the problem):

<?php 
include "db_connect.php";
$tbl_name = "music";

$title = $_REQUEST['title'];
$type = $_REQUEST['type'];

$musicuploaddir = "music/";
$song = $musicuploaddir . basename($_FILES['song']['name']);

mysql_query("INSERT INTO $tbl_name (id, song, title, type) VALUES ('', '$song', '$title', '$type')");
$entrynumber = mysql_insert_id();

if ($song != "music/" && move_uploaded_file($_FILES['song']['tmp_name'], $musicuploaddir))
{
    $songnewname = $musicuploaddir . $entrynumber . ".mp3";
    rename($song, $songnewname);

    mysql_query("UPDATE $tbl_name SET song='$songnewname' WHERE id=$entrynumber") or die( mysql_error() );
    header("Location: music.php?song=$songnewname");
}
?>

HI,

When you say "mp3 file not going to database? do you mean you want to save the actual mp3 file in your database as blob?, or you just want to save the information unique to the mp3 file such as title, duration, and others? If that is what you want, check how it can be done here.

Otherwise, based on your codes above, the uploaded mp3 is being renamed and save in its final destination called music directory.

After the upload, the user is being redirect to another php file named music.php by providing the query string containing the title of the mp3 file.

I am assuming here that in music.php, there are some type codes similar to this.

## pick up the mp3 title from the query string named music

$mp3File = $_GET['music']."mp3";

## there should be some kind player codes here.

How to test my assumptions above? Do a test upload, upon its completion check if there is an mp3 file inside the music directory in your server.

Yes? double check your player codes and make sure the extension mp3 is added , or the proper file name of the mp3 itself matches with the value of music extracted from the query string.

No? Check and make sure the directory named music has the proper permssion or CHMOD. Most server needs at least 755 or 777 for the any script to write in the directory.

Check your php.ini file and make sure the upload_max_filesize is set greater than the file size you are trying to upload.

Again, those are all assumptions and theories based on the codes you have provided us....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.