SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with file upload

    I want to upload multiple files with a form.
    So at the post I have this code that does not work.Why?
    Code:
    if (count($_FILES['presoFile']) > 0) {
            FOREACH ($_FILES['presoFile'] as $name) {
                  if ($name['error'] == 0) {
     $uploadtrumpdir = './files/images/imgs/';
      $uploadtrumpfilename = rand(100000000, 199999999) . "_" . basename($name['presoFile']['name']);
     move_uploaded_file( $name["tmp_name"], $uploadtrumpfile);
    ..............................
    }
    }
    }

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by dimis283 View Post
    ... that does not work.
    What does that mean? Do you get an error?

  3. #3
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The files do not upload,I notice that I can not read the $name["tmp_name"],it is blank.

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Do a var_dump of $_FILES and see what it contains.

  5. #5
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So at the loop how can I get the "error" etc of the files?
    FOREACH ($_FILES['presoFile'] as $index ) {
    // echo($index['name']); //move_uploaded_file($index[$index]["tmp_name"], $uploadtrumpfile);
    var_dump($index);
    }
    array
    2 => string 'poter2.jpg' (length=10)
    3 => string 'b167113.jpg' (length=11)

    array
    2 => string 'image/jpeg' (length=10)
    3 => string 'image/jpeg' (length=10)

    array
    2 => string 'C:\xampp\tmp\php6C46.tmp' (length=24)
    3 => string 'C:\xampp\tmp\php6CA4.tmp' (length=24)

    array
    2 => int 0
    3 => int 0

    array
    2 => int 439439
    3 => int 27730


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
  •