Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected T_STRING

    First, here's my php code: (I put an arrow in line 164)

    PHP Code:
    <?php
    if ((($_FILES["file"]["type"] == "image/jpg")
    || (
    $_FILES["file"]["type"] == "image/pjpeg")
    || (
    $_FILES["file"]["type"] == "image/png"))
    && (
    $_FILES["file"]["size"] < 20000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " $_FILES["file"]["name"] . "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

        if (
    file_exists("uploads/" $_FILES["file"]["name"]))
          {
          
    mkdir("uploads/1/" $_FILES["file"]["name"])
          
    move_uploaded_file($_FILES["file"]["tmp_name"], <--- 164
          
    "upload/1/" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "upload/1/" $_FILES["file"]["name"];
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "upload/" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "upload/" $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo 
    "Please select a file to upload";
      }
    ?>
    The Error: Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 164
    Last edited by Xaqa; 06-16-2011 at 09:53 PM.

  • #2
    New Coder
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    0
    Thanked 17 Times in 17 Posts
    You missed a semi-colon on the line above it.

    mkdir("uploads/1/" . $_FILES["file"]["name"]);

  • Users who have thanked redixx for this post:

    Xaqa (06-16-2011)

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Thanks. Silly me.

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Now I get this error:

    Warning: move_uploaded_file(uploads/1/ad.png) [function.move-uploaded-file]: failed to open stream: Is a directory in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 166

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpkw0Jn8' to 'uploads/1/ad.png' in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 166
    Stored in: uploads/1/ad.png

  • #5
    New Coder
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    0
    Thanked 17 Times in 17 Posts
    Because you just created a directory called $_FILES['file']['name'], and then you try to move your temp file to that folder. You would need something like this instead:

    Code:
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/1/" . $_FILES["file"]["name"] . "/" . $_FILES["file"]["name"]);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •