1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Form finishes submitting, but file doesn't reach destination

Discussion in 'PHP' started by Dryan, Dec 31, 2009.

  1. Dryan

    Dryan New Member

    Joined:
    Dec 31, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I have a php form that I use to send a file to my ftp server. It's supposed to put the file into a folder named uploads. It finishes submitting, but when I check my ftp server, the file isn't there.

    Here's the php:
    PHP:
    <?php
    if (($_FILES["file"]["size"] < 4000000))
      {
      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("upload/" $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "upload/" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "upload/" $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo 
    "Invalid file";
      }
    ?> 
    When it finishes submitting, it sends me to a page that correctly says this:

    Upload: !CID_chinese21.jpg
    Type: image/jpeg
    Size: 25.337890625 Kb
    Temp file: /tmp/phpDoM7tw
    Stored in: upload/image.jpg
     
    Last edited by a moderator: Dec 31, 2009
  2. Dryan

    Dryan New Member

    Joined:
    Dec 31, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    This has been fixed by uploading the form and .php to the root directory.
     

Share This Page