Jump to content

Marco000

New Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Marco000

  1. Try the following code,

     

    for ($i = 0; $i < count($_FILES['imgFile']['name']); $i++){
       $targetPath = "profile_images/";
       $targetPath = $targetPath . basename($_FILES['imgFile']['name'][$i]);
       move_uploaded_file($_FILES['imgFile']['tmp_name'][$i], $targetPath);
    }

     

    Because if you upload multipull images the array looks like

     

    Array
    (
        [pictures] => Array
            (
                [name] => Array
                    (
                        [0] => Image1.jpg
                        [1] => Image2.jpg
                    )
    
                [type] => Array
                    (
                        [0] => image/jpeg
                        [1] => image/jpeg
                    )
    
                [tmp_name] => Array
                    (
                        [0] => C:\xampp\tmp\phpBCCB.tmp
                        [1] => C:\xampp\tmp\phpBCCC.tmp
                    )
    
                [error] => Array
                    (
                        [0] => 0
                        [1] => 0
                    )
    
                [size] => Array
                    (
                        [0] => 33227
                        [1] => 28680
                    )
    
            )
    
    )
    

  2. First of apologies for any inconvenience if this has been posted before as I’m unsure of what it could possibly be called/come under besides something like "reserved variables"?

     

    I have a class that pulls a result out of a database and loads them into class variables by the database field name like the following

     

    // Load the results into the class
    foreach ($array as $name => $value) {
    $this->$name = $value;
    }

     

    This works fine as expected but the problem occurs when I try to echo one of the fields names in the database (it’s called "string") It ends up being like echo $advert->string; and it’s not outputting anything? In Dreamweaver its showing the class variable "string" as a different colour so I’m guessing something isn’t right in terms of "string" being reserved or a function?

     

    How could I get the final/desired output/action I’m looking for here as I’m completely stumped! I normally Google for my solutions but have no idea what I have come across is called.

     

    PS. Sorry for anything I do wrong, just signed up and don’t know the ropes yet in terms of acceptable behaviour, community expectations and ways to post queries.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.