Crop multiple images one by one using jcrop and session in php

I have an image cropping script that crop one image at a time using the jQuery Jcrop plugin . now I want to load more images and crop them one by one using the for loop.

What is the best way to do this?

I set several for my input field so that it can load more than one.

EDIT:

I changed the code below with $maxand count. and I think I'm doing it wrong. how can I fix it, so when I click on the cropping, he visits them after each other.

This is mine uploaded.php:

    <?php 
         session_start();
         $max = count($_FILES['userfile']['name']);
         for($i = 0; $i < $max; $i++){
            $target = $_FILES['file'][$i];
         }

         $target = "data/uploads/"; 
         $target = $target . basename( $_FILES['filename']['name']) ; 
         $_SESSION['target_path'] = $target;

         $ok=1; 
         if(move_uploaded_file($_FILES['filename']['tmp_name'], $target)) 
         {
             echo "De afbeelding *". basename( $_FILES['filename']['name']). "* is geupload naar de map 'uploads'";
         } 
         else 
         {
             echo "Sorry, er is een probleem met het uploaden van de afbeelding.";
         } 
    ?> 

Thank!

+5
source share
2 answers

1) : http://php.net/manual/en/features.file-upload.multiple.php - input name="userfile[]" HTML $_FILES['userfile']['name'][0],...,$_FILES['userfile']['name'][N]

2) move_uploaded_file() - , , , : -)

3) imagemagick library (http://php.net/manual/en/imagick.cropimage.php), , Jcrop demo GD-, imagemagick.

4) , , print_r($variable), .

5) , /tmp-, , php.ini - -. phpinfo()

+1

, - :

<?php 
session_start();

$upload_dir = "data/uploads/"; 
for($i = 0; $i < 5; $i++){
     $target = $upload_dir . basename( $_FILES['file']['name'][$i]);
     if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $target)) {
         echo "De afbeelding *". basename( $_FILES['file']['name'][$i]). "* is geupload naar de map 'uploads'";
     } else {
         echo "Sorry, er is een probleem met het uploaden van de afbeelding.";
     }
}
+1

All Articles