Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Posts
    462
    Thanks
    0
    Thanked 20 Times in 20 Posts

    separating $_Files array

    I need to separate the $_FILES array when multiple upload groups are posted...ex: uploaded_images, uploaded_pdfs

    Currently I thinking of using:
    Code:
    if(isset($_FILES['uploaded']) && !empty($_FILES['uploaded_images'])){
    
    for ($i = 0; $i < count($_FILES['uploaded_images']['name']); $i++) {
    $FileField = ($i+1);
    
    $File          = $_FILES['uploaded_images'];
    $File_Src      = $File['tmp_name'][$i];
    $File_Name     = $File['name'][$i];
    $File_BaseName = basename($File_Name);
    $File_Ext      = substr($File_BaseName, strrpos($File_BaseName, '.') + 1);
    $File_Size     = $File['size'][$i];
    list($File_Width, $File_Height) = getimagesize($File_Src);
    $File_Type     = $File['type'][$i];
    $File_Error    = $File['error'][$i];
    
    
    $EntryStr  = $File_Src.'|';
    $EntryStr .= $File_Name.'|';
    $EntryStr .= $File_BaseName.'|';
    $EntryStr .= $File_Ext.'|';
    $EntryStr .= $File_Size.'|';
    $EntryStr .= $$File_Width.'|';
    $EntryStr .= $File_Height.'|';
    $EntryStr .= $File_Type.'|';
    $EntryStr .= $File_Error.'|';
    
    uploaded_images[]= $EntryStr;
    
    
    }//[end forLoop]
    }
    but seems like there should be an easier way. I need each file upload group array written like the EntryStr above.
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #2
    New Coder
    Join Date
    Apr 2014
    Location
    Daytona Beach, FL
    Posts
    50
    Thanks
    0
    Thanked 1 Time in 1 Post
    No thats how i would do it.

    You could try to expload the array and see what happens though. I havent ever had to deal with file uploading before but it looks like the $_FILE is an $_FILES['uploaded_images']


    Tell me what you get when you do this:
    if(isset($_FILES['uploaded']) && !empty($_FILES['uploaded_images'])){
    vardump($_FILES['uploaded_images']);
    }


    Tell me what you get and maybe ill be able to assist you from there.

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,043
    Thanks
    15
    Thanked 240 Times in 240 Posts
    You just need to use conditional statements based on $_FILES['type'] because $_FILES is already a two dimensional array. A good deal of work depending on how many types you have, but unavoidable.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.


  •  

    Posting Permissions

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