mp3 file upload code in php

Solutions on MaxInterview for mp3 file upload code in php by the best coders in the world

showing results for - "mp3 file upload code in php"
Brett
05 Nov 2017
1<form class='form1' action='../inc/soundclips.php' method='post'     
2                                                   enctype='multipart/form-data'>
3   <input type="hidden" name="id" value="<?php echo $pid; ?>"/>
4   <b>Add Soundclip For <i><?php echo $e;?></i> </b> 
5   <?php echo"<divclass='editimage'>";
6   echo "<img class='resizedimage' src='{$row['image']}' />";
7   echo"</div>";?><br /> 
8   <b>Song</b><br /><input type=text size='60' name='asong' /><br />
9   <input name='file' type="file" id="file"  /><br />
10   <input type='submit' name='add' value='Add Soundclip' />
11</form>
12
Raphael
29 Oct 2016
1 $allowedExts = array("mp3", "jpeg", "jpg", "png");
2 $temp = explode(".", $_FILES["file"]["name"]);
3 $extension = end($temp);
4
5 if ((($_FILES["file"]["type"] == "audio/mp3")
6        || ($_FILES["file"]["type"] == "image/jpeg")
7        || ($_FILES["file"]["type"] == "image/jpg")
8        || ($_FILES["file"]["type"] == "image/pjpeg")
9        || ($_FILES["file"]["type"] == "image/x-png")
10        || ($_FILES["file"]["type"] == "image/png"))
11        && in_array($extension, $allowedExts))
12{
13   if ($_FILES["file"]["error"] > 0)
14   {
15      echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
16   }
17   else
18   {
19      echo "Upload: " . $_FILES["file"]["name"] . "<br>";
20      echo "Type: " . $_FILES["file"]["type"] . "<br>";
21      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
22      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
23
24      if (file_exists("../soundclips/" . $_FILES["file"]["name"]))
25      {
26         echo $_FILES["file"]["name"] . " already exists. ";
27      }
28      else
29      {
30         move_uploaded_file($_FILES["file"]["tmp_name"],
31         "../soundclips/" . $_FILES["file"]["name"]);
32         echo "Stored in: " . "../soundclips/" . $_FILES["file"]["name"];
33      }
34   }
35}
36else
37{
38    echo "Invalid file";
39}
40