uploading multiple files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ogo796
    New Member
    • Jan 2008
    • 44

    uploading multiple files

    hi everyone
    i have a problem with uploading two files at the at the same time.
    cause the code below tells me that invalid supply argument forach.
    [php]
    destfile = /pathe/to/directory;
    foreach ($_FILES["uploaded"]["error"] as $key => $error)
    {
    if ($error == UPLOAD_ERR_OK)
    {
    $tmp_name = $_FILES["uploaded"]["tmp_name"][$key];
    $name = $_FILES["uploaded"]["name"][$key];
    if(move_uploade d_file($tmp_nam e, $destfile ))
    {
    echo"copied successfully to:".$destfile. "<br>";
    }
    else
    {
    echo"failed to copy the files to:".$destfile. "<br>";
    }

    }
    }[/php]

    After so many posts (31) you know that you must include all code within the appripriate code tags. - moderator
    Last edited by ronverdonk; Feb 29 '08, 11:28 AM. Reason: code within tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Can't see anything wrong with it..
    Can you post the form?
    USE CODE TAGS.

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Line 8:[php]if(move_uploade d_file($tmp_nam e, $destfile."/".$name))[/php]

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by hsriat
        Line 8:[php]if(move_uploade d_file($tmp_nam e, $destfile."/".$name))[/php]
        Nice spot, but it was a problem with the foreach arguments?

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Line 1:[php]$destfile = "/pathe/to/directory";[/php]

          @Mark, may be not ... :-/
          Last edited by hsriat; Feb 29 '08, 12:49 PM. Reason: 'not' added

          Comment

          Working...