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
Share on other sites

I haven't had to deal with that for a while, but I would check that both images and projects are chmodded. In addition, I would put a ' or die("Yup its move_uploaded_file"); on that move statement. You could also check the server PHP error log to see what could be happening.

Link to comment
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...

Link to comment
Share on other sites

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
                )

        )

)


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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