0

i'm creating a simple content management system for a website and i want to upload two images one is a thumbnail and the other is something like 1920 x 5036 px . I have this:
HTML (upload.html):

<form action="upload.php" method="post" enctype="multipart/form-data">
    <p>Pictures:
        <input type="file" name="img[]" />
        <input type="file" name="img[]" />
        <input type="submit" value="Send" />
    </p>
</form>


PHP (upload.php) :

$uploaddir = 'images/';
foreach ($_FILES["img"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK){
        $tmp_name = $_FILES["img"]["tmp_name"][$key];
        $name = $_FILES["img"]["name"][$key];
        move_uploaded_file($tmp_name, "images/$name");
    }
}


php.ini:

memory_limit=500M
max_input_time=300
post_max_size=40M
upload_max_filesize=10M
max_file_uploads=10


The first image i'm uploading have the next specs:
name: project02_thumb
1900 x 1307 px
1.69 MB

That image get's uploaded, and moving to the right folder.


The Second image specs:
name: project02
1920 x 5036 px
3.19 MB

The second image never gets uploaded. What can i do more?

i dont get any error on the screen.

Solution

The problem was not from the high resolution images.
I had to change upload_max_filesize and post_max_size to 40M in ALL PHP.INI files.
with xampp v3.2.2
in C:\xampp\php there are 3 files with php.ini name.


php.ini
php.ini-development
php.ini-production

3 Answers3

0

HTML Form:

<input name="files[]" type="file" multiple="multiple" />

PHP Script:

set_time_limit(0);

error_reporting(E_ALL); //testing purpose

$total = count($_FILES['files']['name']); //count files

for($i=0; $i<$total; $i++) { //loop each file

  $tmp_loc = $_FILES['files']['tmp_name'][$i]; //get temp path


  if ($tmp_loc!= ""){

    $new_loc = "./<<directory>>/" . $_FILES['files']['name'][$i]; //setup new location


    if(move_uploaded_file($tmp_loc, $new_loc)) //move file temp dir to new location

    }
  }
}
0

make max_input_time=-1 i.e make time limit more

jinal
  • 1
  • 1
  • can u just print ($_FILES["img"]["error"]);exit; what kind of error you are getting when u upload that image. – jinal Jun 12 '16 at 00:33
0

Maybe it's max_execution_time
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.
The defaultvalue is set by 30