I'm trying to upload .js files onto my sever. This is the code:
<html>
<head>
<title>Add Ubiquity Command</title>
</head>
<body>
<form action="add_ubiquity_cmd.php" method="post" enctype="multipart/form-data">
Name: <input type="text" name="name" /><br />
Description: <textarea rows="8" cols="30" name="description"></textarea><br />
JS File: <input type="file" name="file"><br />
<input type="submit" value="Add Command" /><br/>
</form>
<?php
if(isset($_POST["name"]))
{
$con = mysql_connect("localhost", "usr", "pass");
mysql_select_db("alecbenz_general");
if($_FILES["file"]["error"] > 0)
{
echo "Error: ".$_FILES["file"]["error"];
}
elseif($_FILES["file"]["type"] != "application/x-javascript")
{
echo "Error: file not a Javascript file";
}
elseif(file_exists("../ubiquity/".$_FILES["file"]["name"]))
{
echo "Error: filename already being used.";
}
else
{
if(!(move_uploaded_file($_FILES["file"]["tmp_name"],"/ubiquity/".$_FILES["file"]["name"])))
{
$error = error_get_last();
echo "Error uploading file:<br />Type:".$error["type"]."<br />Message:".$error["message"];
}
else
{
echo "File uploaded<br />";
$sql = "INSERT INTO ubiquity_cmds (name,description,js_filename) VALUES(".$_POST["name"].",".$_POST["description"].",".$_FILES["file"]["name"].")";
if(mysql_query($sql,$con))
{
echo "Command added";
}
else
{
echo "Error adding command: ".mysql_error();
}
}
}
}
?>
</body>
</html>
I get this error:
Error uploading file:
Type:2
Message:move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuveovn' to '/ubiquity/cmd_echo.js'
Anyone know what a possible problem might be?