djcubez Posted April 2, 2008 Share Posted April 2, 2008 I'm trying to make a script to upload mp3's to my personal musician site buuuut it doesn't seem to want to work with mp3's. Any other file it uploads fine but for some reason I keep getting an error with this and mp3's: <?php include("../include/header.php"); if($_GET["upload"] == "") { ?> <b>Add A Song</b><br /> <form enctype="multipart/form-data" action="music.php?upload=1" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000000" /> Song Name: <input name="songname" type="text" /><br /> Song Length: <input name="length" type="text" /><br /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> <?php } elseif($_GET["upload"] == "1") { if ($_FILES["uploadedfile"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { // Determine File Size in MB $size = $_FILES["uploadedfile"]["size"] / 1048576; //Determine Link Path $link = "/music/" . $_POST["songname"] . ".mp3"; // Determine Date $date = time(); // Feedback echo "Upload: " . $_FILES["uploadedfile"]["name"] . "<br />"; echo "Type: " . $_FILES["uploadedfile"]["type"] . "<br />"; echo "Size: " . ($_FILES["uploadedfile"]["size"] / 1024) . " Kb<br />"; echo "Size: " . $size . " Mb<br />"; echo "Link: domainname" . $link . "<br />"; echo "Length: " . $_POST["length"] . "<br />"; echo "Stored in: " . $_FILES["uploadedfile"]["tmp_name"] . "<br />"; // Where the file is going to be placed $target_path = "../music/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . $_POST["songname"] . ".mp3"; if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $query = "INSERT INTO music(title, length, date, size, link) VALUES('$_POST[songname]', '$_POST[length]', '0', '$size', '$link')"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "There was an error uploading the file, please try again!"; } echo "<br /><a href=\"music.php\">Back</a>"; } } include("../include/footer.php"); ?> It stops at the first part of the processing bit yet all it says is "Error: " and doesn't list anything after. Not very helpful. Quote Link to comment Share on other sites More sharing options...
djcubez Posted April 2, 2008 Author Share Posted April 2, 2008 Alright guess I can't edit my post again. I changed the part where it says "file" to "uploadedfile" so I figured out why it wasn't showing me the error. But now, instead of showing me an error it just says "Error: 1". Quote Link to comment Share on other sites More sharing options...
djcubez Posted April 2, 2008 Author Share Posted April 2, 2008 Alright it has nothing to do with file type, it's about file size. But I thought I had enough zeroes in there.... Seriously though, nothing over 2mb is uploading. EDIT: Found this in my php.ini ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = ; Maximum allowed size for uploaded files. upload_max_filesize = 2M Stupid stuff blech. Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 2, 2008 Share Posted April 2, 2008 Check the max upload size in the php.ini file. That sets the real max file upload size. The restriction you are putting in your script is only cosmetic. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.