Hi
I tried to upload the music file same as the image file. but its not getting stroed.
*My action file is as follows-act.php >>
CODE
<?
$dir= "musiclib/";
include "admin/include/db.php";
// To get User Id
$query=mysql_query("select * from musiclibrary");
$count=mysql_num_rows($query);
$id=$count+1;
echo $id;
// List of our known photo types
// $known_photo_types = 'audio/mp3 -> mp3';
$known_file_types = array(
'audio/mp3' => 'mp3',
'audio/mpeg' => 'mpeg'
);
$music_uploaded = $_FILES['musicfile'];
if(!array_key_exists($music_uploaded['type'], $known_file_types))
{
echo "Sorry this file is not supported by this module<br />";
}
else
{
$sql=mysql_query("insert into musiclibrary (music_no, music_name, file_name, music_day, cat_id) values('$id','test', '0', '0', '103')");
$result = mysql_query($sql);
$new_id = $id;
$filetype = $music_uploaded['type'];
$extention = $known_file_types[$filetype];
$filename = $new_id.".".$extention;
mysql_query( "UPDATE musiclibrary SET file_name='".addslashes($filename)."' WHERE music_no='".addslashes($new_id)."'" );
// Store the image file into the image directory
copy($music_uploaded['tmp_name'], $dir."/".$filename);
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=act.php\">";
}
mysql_close();
?>
<a href=file.php>back to stor another file</a>
And here is the form >> file.php
<form enctype="multipart/form-data" action="act.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="musicfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
my table is like..
CODE
CREATE TABLE `musiclibrary` (
`music_no` int(11) NOT NULL auto_increment,
`music_name` varchar(100) default NULL,
`file_name` varchar(100) default NULL,
`music_day` decimal(10,0) default NULL,
`cat_id` decimal(10,0) default NULL,
PRIMARY KEY (`music_no`),
UNIQUE KEY `music_no` (`music_no`),
KEY `cat_id` (`cat_id`)
);
One more thing, when I try to upload any audio file its showing "Sorry this file is not supported by this module".
Please tell me why??
[mod edit] please please use code tags!
This post has been edited by hotsnoj: 20 Nov, 2006 - 10:18 AM