2015-01-28 4 views
9

मैं रीस्टफुल webservice का उपयोग कर रहा हूँ। मैं एक समारोह (PHP) के साथ कई तस्वीरें अपलोड कर रहा हूं।डाकिया रीस्टफुल वेब सेवा में एकाधिक फाइलें कैसे भेजें?

मैं $num_files = count($_FILES['myfile']['name']) का इस्तेमाल किया है फ़ाइलों को अपलोड करने के लिए कर रहे हैं की संख्या की गणना करने के लिए लेकिन यह हमेशा 1 देता है:

Image

जब मैं प्रिंट $_FILES['myfile']['name'] या $_FILES यह पिछले छवि देता है।

क्या मुझे लगता है कि एक समय में कई फाइलें भेजने के लिए कोई सेटिंग करना है?

<?php 
if($result=="success") 
{ 
    $num_files = count($_FILES['myfile']['name']); 
    Zend_Debug::dump($num_files); 
    die; 
    for($i=0; $i < $num_files; $i++) 
    { 
     $name = $_FILES["myfile"]["name"][$i]; 
     $temp_path = $_FILES['myfile']['tmp_name'][$i]; 
     $image_name = Helper_common::getUniqueNameForFile($name); 

     echo $image_name; 
     die; 
     // Set the upload folder path 
     $target_path = $originalDirecory."/"; 


     // Set upload image path 
     $image_upload_path = $target_path.$image_name; 
     move_uploaded_file($temp_path, $image_upload_path); 

     //if(move_uploaded_file($temp_path, $image_upload_path)) 
     //{ 
     // Set 800*800 popup thumbnail... 
     // Set popup directory... 
     $thumbnail_directory=$popUpDirectory."/"; 
     // Set thumbnail name... 
     $thumb_name1=$thumbnail_directory.'thumbnail_'.$image_name; 
     // Set width and height of the thumbnail... 
     $thumb_width=800; 
     $thumb_height=800; 
     $thumb1=Helper_common::generateThumbnail($image_upload_path, $thumb_name1, $thumb_width, $thumb_height); 

     //if($thumb) 
     //{ 
      // Set 435*333 thumbnail... 
      // Set thumbnail directory... 
      $thumbnail_directory=$wallDirecory."/"; 
      // Set thumbnail name... 
      $thumb_name2=$thumbnail_directory.'thumbnail_'.$image_name; 
      // Set width and height of the thumbnail... 
      $thumb_width=435; 
      $thumb_height=435; 
      $thumb2=Helper_common::generateThumbnail($image_upload_path, $thumb_name2, $thumb_width, $thumb_height); 

      //if($thumb) 
      //{ 
       // Set 176*176 thumbnail... 
       // Set thumbnail directory... 
       $thumbnail_directory=$galleryDirectory."/"; 
       // Set thumbnail name... 
       $thumb_name3=$thumbnail_directory.'thumbnail_'.$image_name; 
       // Set width and height of the thumbnail... 
       $thumb_width=176; 
       $thumb_height=176; 
       $thumb_smart_resize_3 = Helper_ImageResizer::smart_resize_image($image_upload_path, NULL, $thumb_width, $thumb_height, false, $thumb_name3, false); 
       $thumb3=Helper_common::generateThumbnail($image_upload_path, $thumb_name3, $thumb_width, $thumb_height); 
      //if($thumb) 
      //{ 
       $profile_thumb=$thumb3; 
       // Set 131*131 thumbnail... 
       // Set thumbnail directory.... 
       $thumbnail_directory = $thumbnailsDirectory."/"; 
       // Set thumbnail name.... 
       $thumb_name4 = $thumbnail_directory.'thumbnail_'.$image_name; 
       $thumb_width=131; 
       $thumb_height=131; 
       $thumb_smart_resize_4=Helper_ImageResizer::smart_resize_image($image_upload_path, NULL, $thumb_width, $thumb_height, false, $thumb_name4, false); 
       $thumb4=Helper_common::generateThumbnail($image_upload_path, $thumb_name4, $thumb_width, $thumb_height); 

       } 
+0

कर्ली कोष्ठक अधूरा, मेरा दिन को बचाने आप अनुभाग – Veerendra

उत्तर

22

मुझे समाधान मिला। मैं इस तरह myFile एक सरणी बनाने की जरूरत है: myFile [] :)

+2

के लिए पूर्ण कोड पोस्ट करें कर सकते हैं बहुत सराहना –

+0

डेटा के किसी भी सरणी आप के लिए कर रहे हैं इसके साथ इसका उल्लेख करें [], आपके मामले में आपको सरणी [] के माध्यम से कई फाइलें भेजनी होंगी क्योंकि पोस्टमैन में आपको इसे मुख्य पैरामीटर myfile में उल्लेख करना होगा [] – user3470929

+0

मेरे लिए भी काम किया, धन्यवाद! –

संबंधित मुद्दे