Jump to content

form upload help


tj7723

Recommended Posts

Right now i am stuck. I am trying to make an upload form so i can upload files to my server.

I am some what new to all of this so please take it easy one me

<?php	
$goodExtensions = array('.doc','.docx','.txt','.pdf','.xls','.xlsx','.avi');
$error='';
$uploaddir = '/upload/';
$name = $_FILES['filename']['name'];
$minFileSize=10;

$extension = substr($name, strpos($name,'.'), strlen($name)-1); // no matter what i upload i get "extension not allowed"


if(!in_array($extension,$goodExtensions));
{
$error.="Extension not allowed<br />";
}  

if(filesize($_FILES['filename']['tmp_name']) <= $min_filessize)
{
$error.="File size too small<br />";
}

$uploadfile = $uploaddir . $stem.$extension;
$filename=$stem.$extension;

if($error == '')
{
if(move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile))
{
	echo 'File UPloaded. Thank you.';
} 
}
else{
echo "$error";
}




?> 

Link to comment
https://forums.phpfreaks.com/topic/191188-form-upload-help/
Share on other sites

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.