Results 1 to 2 of 2

Thread: multiple file uploads

  1. #1
    Join Date
    Jun 2010
    Posts
    243

    multiple file uploads

    i am trying to have a multiple file upload form. here is my form code:

    HTML Code:
      <form action="" method="post"
    enctype="multipart/form-data">
        <label for="file">Filename:</label>
        <input type="file" name="file[]" id="file" /><br />
        <input type="file" name="file[]" id="file" /><br />
        <input type="file" name="file[]" id="file" />
        <br />
        <input type="submit" name="uploadFile" value="Upload my Files" />
      </form
    and then my php:

    PHP Code:
    <?php
      $uploadedFile 
    "uploader.php"// $_POST['uploadFile']
      
    $path_parts pathinfo($uploadedFile);
      echo 
    $path_parts['extension'];
      
    if (isset(
    $uploadedFile)) {
        if (((
    $path_parts['extension'] == "php") || ($path_parts['extension'] == "txt"))
        && (
    $_FILES["file"]["size"] < 100000)) // 20000
              
    {
              if (
    $_FILES["file"]["error"] > 0)
            {
                echo 
    "There was an error uploading your file. <br />";
            }
              else
            {
                echo 
    "Upload: " $_FILES["file"]["name"] . "<br />";
                echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
                echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

            if (
    file_exists("users/" $_SESSION['user'] . "/uploads/" $_FILES["file"]["name"]))
              {
                  echo 
    $_FILES["file"]["name"] . " already exists. ";
              }
            else
              {
                  
    move_uploaded_file($_FILES["file"]["tmp_name"],
                  
    "users/" $_SESSION['user'] . "/uploads/" $_FILES["file"]["name"]);
                  echo 
    "This file was successfully uploaded.";
              }
            }
          }
        else
          {
              echo 
    "Invalid file";
          }
    }
    ?>
    does it have to do with the array? i keep on getting an invalid file error message when trying to upload a .txt file

  2. #2
    I think your post is too old anyway i want to suggest software LongPathTool where you can easily fix your file errors and other file size related issue.

Similar Threads

  1. PHP Photo Gallery Multiple File Upload
    By mikebarbaro in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 11 Apr 2011, 07:03 AM
  2. Multiple File FIND/REPLACE Help Needed!
    By eryao in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 29 Dec 2009, 01:07 PM

Posting Permissions

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