0

Well, I am making an upload for people who make games with the Unity game engine. Basically, the engine will build the game and produce an html file and .unity3d file.

here is my html form:

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Index file:</label>
<input type="file" name="file" id="file" />
<br />
<label for="file2">Unity file:</label>
<input type="file" name="file2" id="file2" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

and here is my upload_file script:

<?php
if ((($_FILES["file"]["type"] == "text/html")
&& ($_FILES["file2"]["size"] < 8388608)
&& ($_FILES["file"]["size"] < 8388608)))
{
if($_FILES["file2"]["size"] < 8388608){
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    echo "Return Code: " . $_FILES["file2"]["error"] . "<br />";
    }
  else
    {
    $mb = $_FILES["file2"]["size"] / 1048576;
    echo "Done.";
    echo "<br />";
    echo "Index file: " . $_FILES["file"]["name"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "<br />";
    echo "Unity file: " . $_FILES["file2"]["name"] . "<br />";
    echo "Size: " . ($_FILES["file2"]["size"] / 1048576) . "Mb<br />";
    echo "<br />";
    if($mb < 1){
    echo "Space used: [-------------]";
    }
    else if($mb <= 1){
    echo "Space used: [|------------]";
    }
    else if($mb <= 2){
    echo "Space used: [||-----------]";
    }
    else if($mb <= 3){ 
    echo "Space used: [|||----------]";
    }
    else if($mb <= 4){
    echo "Space used: [|||||--------]";
    }
    else if($mb <= 5){
    echo "Space used: [|||||||------]";
    }
    else if($mb <= 6){
    echo "Space used: [|||||||||----]";
    }
    else if($mb <= 7){
    echo "Space used: [|||||||||||--]";
    }
    else if($mb <= 8){
    echo "Space used: [|||||||||||||]";
    }
    echo "<br />";
    echo "<br />";
    $random = rand(100, 999);
    mkdir($random);
    move_uploaded_file($_FILES["file2"]["tmp_name"],
      "upload" . "/" . $_FILES["file"]["name"]);
      move_uploaded_file($_FILES["file"]["tmp_name"],
      $random . "/index.html");
      
      echo "Location: <a href=http://www.creativecodingstudios.com/Unity/" . $random . "/>http://www.creativecodingstudios.com/Unity/" . $random . "/</a>";
      
    }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

But in order for the file to work, it needs the .unity3d program. And for some reason, it's not copying over. Is there something wrong with my code?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by CreativeCoding
-1

It might be a permissions issue with the folder/directory you are randomly creating. You may need to chmod it after you create it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.