Lytheum Posted June 26, 2007 Share Posted June 26, 2007 Having a bit of trouble. Even when I use a simple file upload script, it loads a while like it's uploading but the file never ends up in the directory. Anyways, I made my own "wrong file type" check. It's poor coding I know, but for whatever reason when I try to upload an mp3,avi,etc, it triggers this still: if($_FILES['userfile']['type'] != "audio/mpeg"){ $fileis = "wrong";} if($_FILES['userfile']['type'] != "audio/x-ms-wma"){ $fileis .= "file";} if($_FILES['userfile']['type'] != "audio/wav"){ $fileis .= "type";} if($fileis == "wrongfiletype"){ echo "Wrong file type. Only audio formats supported."; Any help towards this would be great. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 so this looks at the file type is nothing matches echos the defualt <?php $filetype=$_FILES['userfile']['type']; switch($filetype){ case "audio/mpeg": echo "right type of file"; break; case "audio/x-ms-wma": echo "right type of file"; break; case "audio/wav"; echo "right type of file"; break; default: echo "your file type is not a sound type"; } ?> Quote Link to comment Share on other sites More sharing options...
Lytheum Posted June 26, 2007 Author Share Posted June 26, 2007 Okay, thanks for the code Bit faster + cleaner. Anyway, I still can't upload and am getting the "wrong file type" error even though it is not the wrong file type. <INPUT TYPE="file" NAME="userfile> Browse > song.mp3 > Click upload..Loading.. "your file type is not a sound type" Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 your right for some reason is returning the file extension as unknown/unknown well there is another work around to this if you want to try it this way <?php $filename=$_FILES['userfile']['name']; $filetype=strstr($filename,'.'); switch($filetype){ case '.mp3': echo "right type of file"; break; case '.x-ms-wma': echo "right type of file"; break; case '.wav'; echo "right type of file"; break; default: echo "your file type is not a sound type"; }?> Quote Link to comment Share on other sites More sharing options...
Lytheum Posted June 26, 2007 Author Share Posted June 26, 2007 That seems to work just fine but now nothing happens. My file won't upload. I'm starting to think it is my webserver's settings. Any idea what it may be? EDIT: Got it working by adding this to .htaccess: (Thanks for all your help!) php_value post_max_size 80000000 php_value upload_max_filesize 80000000 php_value magic_quotes_gpc off 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.