Zchoppa
-
Posts
2 -
Joined
-
Last visited
Posts posted by Zchoppa
-
-
I'm trying to create an upload form for my website- I want to restrict the allowed file types to WAV files and not allow any other file types. With the code I'm using, the form does not allow ANY file type. Why is this?
Here's my script:
<?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if (!($uploaded_type == "audio/wav")) { echo "You may only upload WAV files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?>
of course when I comment out the bit " if (!($uploaded_type == "audio/wav")).... " it allows all file types, which I do not want. Thanks
Limiting File Types In Uploading
in PHP Coding Help
Posted
Thanks for the replies, it's on it's way to what I wanted now. Making a lot more sense.
The reason I only allow wav files is because the service I'm offering from this upload form is Audio Mastering, and a wav or at least FLAC file is typically used over a compressed file like an mp3.