Jump to content

PHP Upload & Adding to MYSQL


Recommended Posts

Hi all once again! I would just like to say this forum is amazing!  :happy-04:


I need to upload a file to my server in /StreamIT/media/music

And in the page where you select the file I need there to be some boxes you need to fill in




Category [This needs to be dropdown box]

Is it clean? [A yes/no type thing]


This needs to be on one page and I need it too add those fillouts to a MYSQL database


I also need a php script to get all the fields from the MYSQL database



The code I have so far: [Does not work]



$allowedExts = array("mp3");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "mp3")
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
  if ($_FILES["file"]["error"] > 0)
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    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("music/" . $_FILES["file"]["name"]))
      echo $_FILES["file"]["name"] . " already exists. ";
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "music/" . $_FILES["file"]["name"];
  echo "Invalid file";

And uploadm.php [Works]


<form action="upload_file.php" method="post"
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">


I know I am asking a lot. Thank you guys!

Link to comment
Share on other sites

What have you tried so far? No one is going to sit here and write it completely. The best you'll get is a template. Here's a thing to consider:


20000 bytes is 0.02MB (give or take). That will deny most if not all music files.

It was a test file I didnt want to upload a file that was 10MB for the sake of time. I am a newbie at this so I don't know where to start.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.