cant get my file to upload with the information going to the database.

linkenpark51471

New Member
Messages
27
Reaction score
0
Points
0
why dosn't this work? its to upload an mp3 and with the information you input into the text box's and puts the name of the mp3 into the table on the database



Code:
<?

$con = mysql_connect("localhost","rabble","rabblel");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("rabble", $con);

session_start();
if(!isset($_SESSION["id"])){
header("location:index.php");
}


// start of uploading script
$target_path = "upload/";


$song = $target_path . basename( $_FILES['uploadedfile']['name']);
$person = $_SESSION["id"];





$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "Sorry there was an error with your song, try another";
}

// end of uploading script


$person = $_SESSION["id"];

if(isset($_POST["file"]) && isset($_POST["name"]))
{
$person = $_SESSION["id"];
$file = mysql_real_escape_string(stripslashes($_FILE["file"]));
$name = mysql_real_escape_string(stripslashes($_POST["name"]));
$artist = mysql_real_escape_string(stripslashes($_POST["artist"]));
$type = mysql_real_escape_string(stripslashes($_POST["type"]));

$query = "INSERT INTO music (file, name, artist, genre, person)
    VALUES('$file', '$name', '$artist', '$type', '$person')";
$sql=$query;



if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "Your song has been uploaded!";
}
mysql_close($con)
?> 



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Music Uploader</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<h1>Upload a song!</h1>
every time one of your songs reaches 5 downloads you get paid!


Song File
<br>

<form enctype="multipart/form-data" action="musicuploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<h3>Song File:</h3> <input name="file" type="file" /><br />


<br>
Song Name
<br>
<input type="text" name="name" size="25">
<br>
Artist Name
<br>
<input type="text" name="artist" size="25">
<br>
Type of music (rock, rap, country)
<br>
<input type="text" name="type" size="25">

<br>
<br>

<input type="submit" value="Upload Song">




</form>



</body>
</html>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
File hosting is against the terms of service. Also, your site will likely get suspended for copyright infringement under the Zero Tolerance Policy.

For future reference, "it doesn't work" doesn't tell us anything. State explicitly what you expect to happen and what actually happens, including any error messages. Sample code should be minimized.
 

linkenpark51471

New Member
Messages
27
Reaction score
0
Points
0
all of the files are to be ran on the site, the terms of service say that there cant be any files that dont have anything to do with the website. and for copyright infringement i have a terms of service myself that says you cant upload anything that isnt owned and made by you. so with all that said im still in the green.
i still need help though
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
and for copyright infringement i have a terms of service myself that says you cant upload anything that isnt owned and made by you. so with all that said im still in the green.

As soon as one person uploads "Freebird" your account will be closed with no access.



i still need help though

As mentioned, "It doesn't work" doesn't help find the problem.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
all of the files are to be ran on the site, the terms of service say that there cant be any files that dont have anything to do with the website.
The files must be secondary to the site's purpose; file hosting isn't a legitimate primary purpose. If you were a musician who wanted to distribute your own music on your site, that would be fine. A music sharing site isn't.

The reason file hosting isn't allowed on the free servers is they tend to be a large drain on server resources, which isn't good for anyone else on the server.

and for copyright infringement i have a terms of service myself that says you cant upload anything that isnt owned and made by you.
That won't stop anyone from uploading copyrighted material, nor does it limit your liability. If copyrighted material is uploaded under your account, you could be guilty of indirect infringement.
 

linkenpark51471

New Member
Messages
27
Reaction score
0
Points
0
Oh ok thank you for the help I'll make sure to get it off of my site then, I appriaciate the descriptive answers
 
Top