Index: /extensions/pLoader/trunk/src/Uploader/ImageList.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 3450)
+++ /extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 3451)
@@ -1023,4 +1023,5 @@
             );
 
+            push @{$self->uploaded_images}, $_;
             $uploaded++;
         } else {
@@ -1045,6 +1046,4 @@
         croak "Upload cancelled. ", $@ if $@ ;
         
-        print "image_selection ", Dumper $_;
-        push @{$self->uploaded_images}, $_;
     }
     @{$self->image_selection} if defined 
@@ -1190,5 +1189,5 @@
     # exif from original image
     my $orientation = $self->current_image->exif_metadata->{Orientation};
-    
+
     # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW
     if( $orientation =~ m/Rotate (\d+)/ ){
Index: /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 3450)
+++ /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 3451)
@@ -212,66 +212,91 @@
 
     my $image_id = $hresult->{result}{$original_sum};
-    if(!defined($image_id)){
-    	$self->send_chunks(
-    	    {
+    my $status = 0;
+    my $status_line = "An error has occured during upload.";
+    while(1){
+        if(!defined($image_id)){
+        	
+            my $resized_params = {
                 filepath => encode('iso-8859-1', $self->site_resized_file),
                 type => 'file',
                 original_sum => $original_sum,
-    	    }
-    	);
-
-    	$self->send_chunks(
-    	    {
+            };
+    
+            $self->send_chunks(
+                $resized_params
+            );
+            
+            $status_line = $resized_params->{message};
+            last if !$resized_params->{ok};
+          
+            my $thumb_params = {
                 filepath => encode('iso-8859-1', $self->site_thumb_file),
                 type => 'thumb',
+                original_sum => $original_sum,        	
+            };
+    
+            $self->send_chunks(
+                $thumb_params
+            );
+
+            $status_line = $thumb_params->{message};
+            last if !$thumb_params->{ok};
+
+       	
+            $form = {
+                method            => 'pwg.images.add',
+                original_sum      => $original_sum,
+                file_sum          => $file_sum,
+                thumbnail_sum     => $thumbnail_sum,
+                categories        => $self->categories,
+                name              => $site_image_name,
+                rank              => $self->rank,
+                author            => $self->site_author,
+                comment           => $self->site_comment,
+                date_creation     => $self->site_img_date_creation,
+                
+            };
+            my $high_params = {
+                filepath => encode('iso-8859-1', $self->site_high_file),
+                type => 'high',
                 original_sum => $original_sum,
-    	    }
-    	);
-   	
-        $form = {
-            method            => 'pwg.images.add',
-            original_sum      => $original_sum,
-            file_sum          => $file_sum,
-            thumbnail_sum     => $thumbnail_sum,
-            categories        => $self->categories,
-            name              => $site_image_name,
-            rank              => $self->rank,
-            author            => $self->site_author,
-            comment           => $self->site_comment,
-            date_creation     => $self->site_img_date_creation,
-            
-        };
-    
-        if($self->upload_high){
-            $self->send_chunks(
-    	        {
-                    filepath => encode('iso-8859-1', $self->site_high_file),
-                    type => 'high',
-                    original_sum => $original_sum,
-    	        }
-    	    );
-
-            $form->{high_sum}     = $original_sum;
+            };
+    
+            if($self->upload_high){
+                $form->{high_sum} = $original_sum;
+    
+                $self->send_chunks(
+                    $high_params
+        	);
+
+                $status_line = $high_params->{message};
+                last if !$high_params->{ok};
+    
+            }
         }
-    }
-    else {
-        $form = {
-            method            => 'pwg.images.setInfo',
-            image_id          => $image_id,
-            categories        => $self->categories,
-            name              => $site_image_name,
-            rank              => $self->rank,
-            author            => $self->site_author,
-            comment           => $self->site_comment,
-            date_creation     => $self->site_img_date_creation,
-        };
-    }
-
-    $result = $self->uagent->post(
-        $self->urlbase.'/ws.php?format=json',
-        $form
-    );
-
-    return ( $result->is_success, $result->status_line );
+        else {
+            $form = {
+                method            => 'pwg.images.setInfo',
+                image_id          => $image_id,
+                categories        => $self->categories,
+                name              => $site_image_name,
+                rank              => $self->rank,
+                author            => $self->site_author,
+                comment           => $self->site_comment,
+                date_creation     => $self->site_img_date_creation,
+            };
+        }
+    
+        $result = $self->uagent->post(
+            $self->urlbase.'/ws.php?format=json',
+            $form
+        );
+    
+        $status = $result->is_success;
+        $status_line = $result->status_line; 
+        last;
+    }
+    
+    return ( $status,  $status_line);
 }
  
@@ -336,14 +361,12 @@
         );
 
-        #printf(
-        #    'chunk %05u of %05u for %s "%s"'."\n",
-        #    $chunk_id,
-        #    $nb_chunks,
-        #    $params->{type},
-        #    $params->{filepath}
-        #);
+        $params->{ok} = 1;
         if ($response->code != 200) {
             printf("response code    : %u\n", $response->code);
             printf("response message : %s\n", $response->message);
+            $params->{ok} = 0;
+            $params->{message} = $response->message;
+            $params->{code} = $response->code;
+            last;
         }
 
