Hello this is my first post on this forum. I am an amateur web programmer, self taught, and I'm making a non commercial website to support local musicians. Basically I am having a difficult time scripting a php form for artists to submit their info to me as well as upload an image and an audio file to my remote server for me to preview.
I've been working on this all day and just cant seem to figure it out.
The mailer form data I am grabbing fine and is working but I cannot get files to upload also I don't know how to define the file types allowed for separately in the form.
<?php
if(isset($_POST['submit'])) {
$my_email = "------";
$subject = "New Track";
$email_field = $_POST['email'];
$artist_field = $_POST['artist'];
$artisturl_field = $_POST['artisturl'];
$genre_field = $_POST['genre'];
$loc_field = $_POST['loc'];
$trackn_field = $_POST['trackn'];
$trackurl_field = $type[$_REQUEST['trackurl']];
$body = "Artist: $artist_field\nEmail: $email_field\nURL: $artisturl_field\nGenre: $genre_field\nLoc: $loc_field\nTrack Title: $trackn_field, $trackurl_field";
echo "Thank you for your submission.";
mail($my_email, $subject, $body);
} else {
echo "error data not sent please contact mailbox@massmic.org";
}
if ((($_FILES["file"]["type"] == "audio/mpeg")
|| ($_FILES["file"]["type"] == "audio/x-mpeg")
|| ($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/x-mp3")
|| ($_FILES["file"]["type"] == "audio/mpeg3")
|| ($_FILES["file"]["type"] == "audio/x-mpeg3")
|| ($_FILES["file"]["type"] == "audio/mpg")
|| ($_FILES["file"]["type"] == "audio/x-mpg")
|| ($_FILES["file"]["type"] == "audio/x-mpegaudio")
|| ($_FILES["file"]["type"] == "audio/wav")
|| ($_FILES["file"]["type"] == "audio/x-wav")
|| ($_FILES["file"]["type"] == "audio/x-aiff")
|| ($_FILES["file"]["type"] == "audio/x-aac")
|| ($_FILES["file"]["type"] == "audio/mp4")
|| ($_FILES["file"]["type"] == "audio/m4a")
|| ($_FILES["file"]["type"] == "audio/m4p"))
&& ($_FILES["file"]["size"] < 500000))
{
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("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";
}
?>
That's what I have so far I was just trying to get the song to upload I have not even added the image part. Any help or direction I'd appreciate so much thank you.