clanstyles Posted August 7, 2007 Share Posted August 7, 2007 case addserver: { if(isset($_POST['addserver'])) { $serverinfo['name'] = $_GET['servername']; $serverinfo['pass'] = $_GET['serverpassword']; $serverinfo['enabled'] = $_GET['serverenabled']; if($serverinfo['enabled'] == "on") $serverinfo['enabled'] = true; else $serverinfo['enabled'] = false; echo $_FILES['filename']['name'] . "<br />"; echo $_FILES['filename']['filesize'] . "<br />"; echo $_FILES['filename']['error'] . "<br />"; $realFileName = $_FILES['filename']['name']; $imgname = rand(1, 9999)."-".$_FILES['filename']['name']; copy ($_FILES['filename']['tmp_name'], "keys/".$imgname.$_FILES['filename']['name']) or die ("Could not copy key file." . $_FILES['filename']['error']); $nameofFile = $fileran.$_FILES['profile']['name']; $statment ="INSERT into `servers` (id, name, keyfile, password, enabled) VALUES('null', '" . $nameofFile . "', '" . strip_tags($serverinfo['file']) . "', '" . strip_tags($serverinfo['pass']) . "', '" . strip_tags($serverinfo['enabled']) . "')"; mysql_query($statment) or die (mysql_error()); } ?> <p> <form method="POST" action="?action=addserver" id="addserver" onsubmit="return checkform(this);"> <label for="servername">Server Name: </label><input type="text" name="servername" size="16" /><br /> <label for="filename">File Name: </label><input type="file" name="filename" id="filename" /><br /> <label for="serverpassword">Server Password: </label><input type="password" name="serverpassword" size="16" /><br /> <label for="serverenabled">Server Enabled: </label><input type="checkbox" name="serverenabled"><br /> <div align="center"> <p><input type="submit" value="Add Server" id="addserver" name="addserver" /></p> </div> </form> </p> <?php break; } This always comes up with the error, There was an erropr uploading the key file. Quote Link to comment https://forums.phpfreaks.com/topic/63806-form-help-w-upload/ Share on other sites More sharing options...
ToonMariner Posted August 8, 2007 Share Posted August 8, 2007 you need enctype="multipart/form-data" attribute decalred in your form tag. Quote Link to comment https://forums.phpfreaks.com/topic/63806-form-help-w-upload/#findComment-317998 Share on other sites More sharing options...
clanstyles Posted August 8, 2007 Author Share Posted August 8, 2007 thx I always forget that Quote Link to comment https://forums.phpfreaks.com/topic/63806-form-help-w-upload/#findComment-318661 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.