Search
 
SCRIPT & CODE EXAMPLE
 

PHP

mp3 file upload code in php

 $allowedExts = array("mp3", "jpeg", "jpg", "png");
 $temp = explode(".", $_FILES["file"]["name"]);
 $extension = end($temp);

 if ((($_FILES["file"]["type"] == "audio/mp3")
        || ($_FILES["file"]["type"] == "image/jpeg")
        || ($_FILES["file"]["type"] == "image/jpg")
        || ($_FILES["file"]["type"] == "image/pjpeg")
        || ($_FILES["file"]["type"] == "image/x-png")
        || ($_FILES["file"]["type"] == "image/png"))
        && in_array($extension, $allowedExts))
{
   if ($_FILES["file"]["error"] > 0)
   {
      echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
   }
   else
   {
      echo "Upload: " . $_FILES["file"]["name"] . "<br>";
      echo "Type: " . $_FILES["file"]["type"] . "<br>";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

      if (file_exists("../soundclips/" . $_FILES["file"]["name"]))
      {
         echo $_FILES["file"]["name"] . " already exists. ";
      }
      else
      {
         move_uploaded_file($_FILES["file"]["tmp_name"],
         "../soundclips/" . $_FILES["file"]["name"]);
         echo "Stored in: " . "../soundclips/" . $_FILES["file"]["name"];
      }
   }
}
else
{
    echo "Invalid file";
}
Comment

mp3 file upload code in php

<form class='form1' action='../inc/soundclips.php' method='post'     
                                                   enctype='multipart/form-data'>
   <input type="hidden" name="id" value="<?php echo $pid; ?>"/>
   <b>Add Soundclip For <i><?php echo $e;?></i> </b> 
   <?php echo"<divclass='editimage'>";
   echo "<img class='resizedimage' src='{$row['image']}' />";
   echo"</div>";?><br /> 
   <b>Song</b><br /><input type=text size='60' name='asong' /><br />
   <input name='file' type="file" id="file"  /><br />
   <input type='submit' name='add' value='Add Soundclip' />
</form>
Comment

PREVIOUS NEXT
Code Example
Php :: two condition in one laravel query 
Php :: php list *files 
Php :: FPDF invoice Tutorial 
Php :: How To Force Redirect HTTP To HTTPS In Laravel Using ServiceProvider 
Php :: wordpress - php settings 
Php :: how to wirte laravel dd function in php 
Php :: laravel get all request parameters 
Php :: how to download file from s3 bucket using php 
Php :: Download any version of xampp 
Php :: yii1 refresh cache schema 
Php :: php flatten array 
Php :: php exit 
Php :: random string number generator in php codeigniter 
Php :: laravel 9 excel 
Php :: laravel set production 
Php :: php kommentar 
Php :: bootstrap is not defined in laravel 
Php :: set cookie on button click php or js 
Php :: global variable in laravel controller 
Php :: php epoch conversion 
Php :: Drupal 8 custom form image field 
Php :: laravel create resource 
Php :: install a package only composer dont update 
Php :: error laravel 404 in server 
Php :: sanctum 
Php :: show uploaded image in php 
Php :: what is cors in laravel 
Php :: Add Text After or Before on the Shop Page/Archive Page 
Php :: php detect daylight saving time DST 
Php :: wordpress highlight text excerpt 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =