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

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.