title: How can I upload mp3 files to server in php by ftp?
body: <p>I want to upload mp3 files to server by using ftp in php language.I did a raw code script for this.In server image,pdf,doc files are uploaded but i can not upload mp3 files.</p>
  
  <p>Plz,anyone would help me??I am in serious trouble!!!</p>
  
  <p><strong>It shows file does not exist when i am going to upload mp3 files</strong></p>
  
  <p>Here is my code,--</p>
  
  <pre><code>&lt;?php
  
  // FTP Configuration
  $FTP_User = $_POST["username"];
  $FTP_Pass = $_POST["password"];
  $FTP_Host = "###";
  $FTP_Root = "$dir";
  
    $action=$_GET["action"]; 
    $username=$_POST["username"];
    $password=$_POST["password"];
    $dir=$_POST["dir"]; 
    $Filename=$_POST["Filename"];
    $MAX_FILE_SIZE= $_POST["MAX_FILE_SIZE"]; 
  
  // If the form was submitted
  if (isset($action) &amp;&amp; $action == "submit") {
  
  if ($_FILES['File_1']['size'] &gt; $MAX_FILE_SIZE)
  {
  echo "Error: $Filename exceeds upload limit";
  exit;
  }
  
  echo $_FILES['File_1']['size'];
  echo $MAX_FILE_SIZE;
  
  if ($dir == "-1")
  {
  echo "Error: Please choose a File Type to upload";
  exit;
  }
  
  // Connect to the ftp address
  $Connect = ftp_connect($FTP_Host);
  
  if (!$Connect)
  {
  echo "Error: Could not connect to ftp server&lt;br&gt;";
  exit;
  }
  
  echo "Connected to $FTP_Host&lt;br&gt;";
  
  // Login
  $login = ftp_login($Connect, $FTP_User, $FTP_Pass);
  
  //Turns passive mode on
  $passive = ftp_pasv ($Connect, true );
  
  echo "Current directory is now: " . ftp_pwd($Connect) . "&lt;br&gt;";
  
  if (ftp_chdir($Connect, "$FTP_Root"))
  {
  echo "Current directory is now: " . ftp_pwd($Connect) . "&lt;br&gt;";
  } else echo "Cannot change directory";
  
  $contents = ftp_nlist($Connect, ".");
  
  // output $contents
  print_r($contents);
  
  // check upload status
  if (!passive){
  echo "Failed to enter passive mode.&lt;br&gt;";
  }
  else {
  echo "Entered passive mode.&lt;br&gt;";
  }
  
  if (!$login)
  {
  echo "Error: Could not log on as $FTP_User&lt;br&gt;";
  ftp_quit($Connect);
  exit;
  }
  
  echo "Logged in as $FTP_User&lt;br&gt;";
  
  // Set the filename to be uploaded
  $Filename = $_FILES['File_1']['name'];
  $myFile = $_FILES['File_1'];
  
  //echo 'Filename is :'. $Filename;
  print_r($myFile);
  if (file_exists($Filename))
  {
  echo "The file $Filename exists&lt;BR&gt;";
  }
  else
  {
  echo "The file $Filename does not exist&lt;BR&gt;";
  }
  
  $destination_file = $FTP_ROOT.$_FILES['File_1']['name'];
  
  // Set the local resource (the file that will be uploaded)
  $file = $myFile['tmp_name'];
  
  // If the file was successfully uploaded
  $upload = ftp_put($Connect, $destination_file, $file, FTP_BINARY);
  
  if (!$upload)
  {
  // Show success message
  echo "There was a problem uploading $destination_file";
  }
  else
  {
  // Else show error message
  echo "Successfully uploaded $Filename";
  
  }
  ftp_close($Connect);
  }
  
  ?&gt;
  
  Form Code:
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; PHP FTP Upload Test &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table&gt;
  &lt;form method="post" action="file_upload.php?action=submit" enctype="multipart/form-data"&gt;
  &lt;input type="hidden" name="MAX_FILE_SIZE" value="10000000"&gt;
  &lt;tr&gt;
  &lt;td&gt;Username:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="username" size="30"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password:&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" name="password" size="30"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;File Type:&lt;/td&gt;
  &lt;td&gt;&lt;select name="dir"&gt;
  &lt;option value="-1"&gt;File Type&lt;/option&gt;
  &lt;!--&lt;option value="/httpdocs/charbel/upload/"&gt;Image&lt;/option&gt;
  &lt;option value="/httpdocs/charbel/upload/"&gt;PDF&lt;/option&gt;
  &lt;option value="/httpdocs/charbel/upload/"&gt;MP3&lt;/option&gt;
  &lt;option value="/httpdocs/charbel/upload/"&gt;Video&lt;/option&gt;
  --&gt;
  &lt;option value="/public_html/"&gt;Image&lt;/option&gt;
  &lt;option value="/public_html/"&gt;PDF&lt;/option&gt;
  &lt;option value="/public_html/"&gt;MP3&lt;/option&gt;
  &lt;option value="/public_html/"&gt;Video&lt;/option&gt;
  
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;File:&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" name="File_1" size="70"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan="2" align="right"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/form&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>