There we go mudi:
<form enctype="multipart/form-data" action="" method="post">
Song Artist: <input type="text" name="artist" /><br>
Song Name: <input type="text" name="name" /><br>
MP3 File: <input type="file" name="file" /><br>
<input type="submit" value="Submit" name="Submit" />
</form>
<?php
if(strlen($_FILES['file']['name']) > 1)
{
$file = basename($_FILES['file']['name']);
$name = $_POST['name'];
$artist = $_POST['artist'];
$ext = strtolower(substr(strrchr($file, '.'), 1));
$allowedExt = array('mp3');
$uploadPath = "musics";
if(!is_dir($uploadPath))
{
mkdir($uploadPath,"0777");
}
$uploadPath = $uploadPath."/".$file;
$size = $_FILES['file']['size'] / 1024; // size in kb
$maxSize = 10024; //size in kb
if(in_array($ext, $allowedExt) and $size < $maxSize)
{
if (file_exists($uploadPath))
{
echo "The file already exists!";
}
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadPath))
{
echo "The mp3, $file was uploaded successfully and added to the playlist!";
$file = 'config.xml';
$handle = fopen($file, 'r');
$size=filesize($file);
$size=$size-21;
$contents = fread($handle, $size);
$contents = $contents."#".$uploadPath.",".$artist." - ".$name."</play_list></config>";
fclose($handle);
$file = 'config.xml';
$handle = fopen($file, 'w');
fwrite($handle, $contents);
fclose($handle);
}
else
{
echo "An error ocurred during upload. Try again later";
}
}
}
else
{
echo "File format is unsupported or filesize is too big";
}
}
?>
I have just started learning PHP so correct the mistakes but it works fine, no problems at all!
Name!!! Holy crap, thats gonna take one hell of a script...