SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Uploading files?

    I am trying to upload several files but it dosnt work. Can anybody tell what i am doing wrong?


    <FORM ACTION="upload.php" METHOD="POST" encrypt="multipart/form-data">
    <tr><td>Fil 1/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 2/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 3/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 4/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 5/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 6/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 7/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 8/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 9/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 10/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 11/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td>Fil 12/td><td><input name="thefile[]" type="file"></td></tr>
    <tr><td><td colspan="2"><input type="submit" value="UPLOAD"></td></tr></FORM>


    PHP Code:

    // upload.php

    $thefile $_POST['thefile'];

    for (
    $i=0$i<count($thefile); $i++) {

     
    $tmp $_FILES['thefile']['tmp_name'][$i];

    $filename time() .jpg;
    $file "c:/data/voice/arkiv/" $filename;

    if (
    is_uploaded_file($tmp) AND copy($tmp$file)) {


    }

       } 

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    New Jersey
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change encrypt="multipart/form-data" to enctype="multipart/form-data".

  3. #3
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also change

    PHP Code:
    $filename time() .jpg
    To

    PHP Code:
    $filename time() '.jpg'

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The strange thing is that when i use enctype instead of encrypt it dosnīt count the arrays thefile ?

  5. #5
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Consider using a variable for the path, makes it easier if you ever want to use the script elsewhere.
    $file = "c:/data/voice/arkiv/" . $filename;
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the answer to my question. i used $thefile = $_POST['thefile']; instead of
    $thefile = $_FILES['thefile'];


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
  •