Mp3 file upload fail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zactanaz
Forum Newbie
Posts: 4
Joined: Sun Jan 16, 2005 2:53 pm
Location: California,USA

Mp3 file upload fail

Post by zactanaz »

Ok i have this file upload code, and everything seems to go right, but the file does not get uploaded.

Form:

Code: Select all

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\">\n";
			echo "  <tr>\n";
			echo "    <td width=\"100%\">\n";
			echo "    <p align=\"center\">Subir Cancion (Mp3)</td>\n";
			echo "  </tr>\n";
			echo "  <tr>\n";
			echo "    <td width=\"100%\">&nbsp;</td>\n";
			echo "  </tr>\n";
			echo "  <tr>\n";
			echo "    <td width=\"100%\">\n";
			echo "    <p align=\"center\">Seleccione Archivo:</td>\n";
			echo "  </tr>\n";
			echo "  <tr>\n";
			echo "    <td width=\"100%\">\n";
			echo "    <form method=\"POST\" enctype=\"multipart/form-data\" action=\"modules.php?name=$modulename&file=admin\">\n";
			echo "      <p align=\"center\"><input type=\"file\" name=\"mp3\" size=\"40\"><br>\n";
			echo "      <br>\n";
			echo "      <input type=\"submit\" value=\"Subir\"></p>\n";
			echo "      <input type=\"hidden\" name=\"lid\" value=\"$lid\">\n";
			echo "      <input type=\"hidden\" name=\"op\" value=\"mp3upload\">\n";
			echo "    </form>\n";
			echo "    </td>\n";
			echo "  </tr>\n";
			echo "</table>\n";
and for the upload:

Code: Select all

$mp3url_name = $_FILES['mp3']['name'];
        $mp3url_temp = $_FILES['mp3']['tmp_name'];
        $ext = substr($mp3url_name, strrpos($mp3url_name,'.'), 5);
        $new_file_name = "song_$lid$ext";
        if (move_uploaded_file($mp3url_temp, "modules/$modulename/music/$new_file_name")) {
            chmod("modules/$modulename/music/$new_file_name", 0755);
            $mp3url = "modules/$modulename/music/$new_file_name";
        }

I used phpnuke just in case. Thanks.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Try using the whole document path:

Code: Select all

modules/$modulename/music/$new_file_name

Code: Select all

/http/myserverpath/modules/$modulename/music/$new_file_name
zactanaz
Forum Newbie
Posts: 4
Joined: Sun Jan 16, 2005 2:53 pm
Location: California,USA

Post by zactanaz »

ok i tried it.. but still the same..

seem to go fine... no upload
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

What errors are you getting?

Did you do a is_dir() on the directory?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

MAX_POST_SIZE (or something like that)

cannot post files larger than 4M by default. (only server admin can modify this)
Post Reply