Hello Dynamic Drive, I have a problem which I sadly could not resolve searching the forum. I want to have the user upload .wav files. I then want the file information displayed, and the file stored.
The condition($_FILES["file"]["type"] == "audio/wave")or "audio/wav" seem to be incorrect so I removed it from my code to make sure the rest of my code was working. This is where I become truly confused. I can upload any type of file except .wav files. When I try to upload a wave it echos "Error 2".
I'm posting my code without the file[type] condition. I would like to know if there is any way to upload only wave files if at all.
My Form:
My PHP:Code:<form action="submit_sample.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="100000"/> Upload sample: <input type="file" name="file" tabindex="1"> <br> <input type="submit" value="Submit Sample" name="submit" tabindex="2"> </form>
I'm really stuck here, any advice would be wonderful.Code:<?php if ($_FILES["file"]["size"] < 900000) // originally if (($_FILES["file"]["type"] == "audio/wave") && ($_FILES["file"]["size"] < 900000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"]; move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } else { echo "Invalid file type or size"; } ?> <a href="sample.php">Return to step 3</a>



Reply With Quote


Bookmarks