Results 1 to 10 of 10

Thread: Create an Upload-File Form

  1. #1
    Join Date
    Apr 2005
    Posts
    46,704

    Default Create an Upload-File Form

    Create an Upload-File Form

    Code:
    <html>
    <body>
    
    <form action="" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    </body>
    </html
    
    <?php
    
    if (isset ($_FILES["file"] ["error"]))
    
    {
    if ($_FILES["file"]["error"] > 0)
      {
      echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"];
      }
    
    }
    
    ?>
    Last edited by minisoji; 11-15-2011 at 10:52 AM.

  2. #2
    Join Date
    Apr 2005
    Posts
    46,704

    Default


    Restrictions on Upload



    Code:
    <html>
    <body>
    
    <form action="form.php" method="post" enctype="multipart/form-data">
    
     <label for="file">Filename:</label>
    
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    </body>
    </html> 
    
    <?php
    
    if (isset($_FILES["file"]["type"]))
    
    {
    if ((($_FILES["file"]["type"] == "image/gif")
    
    || ($_FILES["file"]["type"] == "image/jpeg")
    
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    
    && ($_FILES["file"]["size"] < 50000))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"];
        }
      }
    else
      {
      echo "Invalid file";
      }
    }
    ?>
    Last edited by minisoji; 12-03-2011 at 10:53 AM.

  3. #3
    Join Date
    Jan 2012
    Posts
    5

    Default

    thx this help me much

  4. #4
    Join Date
    Jan 2012
    Posts
    5

    Default

    thx for this help me verry much

  5. #5
    Join Date
    Feb 2012
    Posts
    1

    Default

    Thanks for sharing. It's geat
    __________________
    be naughty review

  6. #6
    Join Date
    Apr 2012
    Posts
    6

    Default

    it's not hard to study

  7. #7
    Join Date
    Apr 2012
    Posts
    6

    Default

    ty ty ty ty

  8. #8
    Join Date
    Jun 2012
    Posts
    5

    Default

    Thanks ..I really needed this for my website.

  9. #9
    Join Date
    Jul 2012
    Posts
    3

    Default

    hi very nice thread and its very help full for us....
    website design

  10. #10
    Join Date
    Nov 2012
    Posts
    5

    Default

    Creating a file upload form with PHP
    Creating a file upload form with PHP

Bookmarks

Posting Permissions

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