New and need help

I’ve cobbled to together an upload form from other snippets of code. I’m trying to allow users to upload music files to my website so that I can master them. I’ve limited them to .wav,.zip, or.rar. I thought I had figured out the email notification bit, but it still is not working consistently. I also cant figure out how to get the email to tell me which client has uploaded.

Another issue I’m having is that large files, the size typical of an audio file, are returning the error, “Invalid File”. The script works perfectly on small test files. Here’s the code I’m using. Any help would be greatly appreciated. Thanks.

<?php $allowedExts = array("wav", "zip", "rar"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "audio/wav") || ($_FILES["file"]["type"] == "application/octet-stream")) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } if ( $err_num == 0 ) { $message = $_FILES["file"]["name"]; mail('[email protected]', 'Uploaded File', $message); } ?>

Just read the “Read This First” post. Sorry, here’s the code in a more readable fashion. Thanks again.

[php]<?php
$allowedExts = array(“wav”, “zip”, “rar”);
$extension = end(explode(".", $_FILES[“file”][“name”]));
if ((($_FILES[“file”][“type”] == “audio/wav”)
|| ($_FILES[“file”][“type”] == “application/octet-stream”))
&& in_array($extension, $allowedExts))
{
if ($_FILES[“file”][“error”] > 0)
{
echo "Return Code: " . $_FILES[“file”][“error”] . “
”;
}
else
{
echo "Upload: " . $_FILES[“file”][“name”] . “
”;

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

}
else
{
echo “Invalid file”;
}

if ( $err_num == 0 )
{
$message = $_FILES[“file”][“name”];
mail(‘[email protected]’, ‘Uploaded File’, $message);
}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service