Jump to content

multiple file upload


AviNahum

Recommended Posts

hey, i tried to upload a multiple files...

this is my code:

 

<?php

        if(isset($_FILES['images']['tmp_name']))
        {
            // Number of uploaded files
            $num_files = count($_FILES['images']['tmp_name']);

            for($i=0; $i < $num_files;$i++)
            {
                $random = rand(0,1000000000000000000);
                $_FILES["images"]["name"][$i] = "".$random."_".$_FILES["images"]["name"][$i]."";
                $type = $_FILES["images"]["type"][$i];
                $at = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png");

                // We allow only images file types
                if (!in_array($type, $at) )
                            return $core->error("אחד הקבצים או יותר שהעלת אינם בפורמט מתאים.");

                if ($_FILES["images"]["name"][$i] > 0)
                        return $core->error("{$_FILES["images"]["name"][$i]}");

                move_uploaded_file($_FILES["images"]["name"][$i], "images/projects/" . $_FILES["images"]["name"][$i]);
                $_POST['images'] .= $_FILES["images"]["name"][$i].",";
            }
        }

?>

 

for some reason move_uploaded_file doesnt work...

it's just not moving the files to this directory...

the folder i trying to upload the files has 777 permissions so thats not the problem...

any ideas?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/203296-multiple-file-upload/
Share on other sites

Yeah, had the same problem last week, then I discovered that it isn't the upload folder that needs permissions, it's the entire folder in which your script that uses the move_uploaded_folder that needs 777... And use: ini_set('display_errors', 1); at the top of your script, to locate the error...

output of

echo "<pre>".print_r($_FILES, true)."</pre>";


Array
(
    [images] => Array
        (
            [name] => Array
                (
                    [0] => -201707379_unix-hd-wallpaper-1.jpg
                    [1] => -1169662749_Ubuntu_Bokeh_by_ttk1opc.png
                    [2] => -699814691_mikro_sine-shape-04-Hi-wallpaper-HD.jpg
                    [3] => -870034778_mikro_sine-shape-04-Hi-wallpaper-HD.jpg
                )

            [type] => Array
                (
                    [0] => image/jpeg
                    [1] => image/png
                    [2] => image/jpeg
                    [3] => image/jpeg
                )

            [tmp_name] => Array
                (
                    [0] => /tmp/phpWyjLH0
                    [1] => /tmp/phpcdtSnL
                    [2] => /tmp/phpHguf4v
                    [3] => /tmp/phpUkLILg
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                    [2] => 0
                    [3] => 0
                )

            [size] => Array
                (
                    [0] => 298835
                    [1] => 203598
                    [2] => 886080
                    [3] => 886080
                )

        )

)


Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.