Jump to content

[SOLVED] Uploading Via Web Form


Lytheum

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/57316-solved-uploading-via-web-form/
Share on other sites

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";
}
?>

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"

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";
}?>

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

 

Archived

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.