+ Reply to Thread
Results 1 to 6 of 6

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

  1. #1
    linkenpark51471 is offline x10Hosting Member linkenpark51471 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    26

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

    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>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

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

    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.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    linkenpark51471 is offline x10Hosting Member linkenpark51471 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    26

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

    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

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

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

    Quote Originally Posted by linkenpark51471 View Post
    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.
    Nothing is always absolutely so.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

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

    Quote Originally Posted by linkenpark51471 View Post
    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.

    Quote Originally Posted by linkenpark51471 View Post
    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.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    linkenpark51471 is offline x10Hosting Member linkenpark51471 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    26

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

    Oh ok thank you for the help I'll make sure to get it off of my site then, I appriaciate the descriptive answers

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 06-26-2011, 01:12 PM
  2. upload .net file and create sql server database
    By nkd10824 in forum Free Hosting
    Replies: 0
    Last Post: 07-05-2010, 06:10 AM
  3. Replies: 2
    Last Post: 11-01-2008, 09:48 PM
  4. Replies: 1
    Last Post: 09-20-2008, 02:12 AM
  5. File upload, PHP into a SQL database blob (move_uploaded_files)
    By altrock182182 in forum Programming Help
    Replies: 3
    Last Post: 02-11-2008, 07:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers