我正在使用ReSTful webservice。我正在使用一个功能(PHP)上传多张照片。
我使用$num_files = count($_FILES['myfile']['name'])
来计算要上传的文件数量,但这总是给出1:
当我打印$_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 :(得分:41)
我有一个解决方案。 我需要使myfile成为这样的数组: myfile []:)
答案 1 :(得分:7)
更新2020年邮递员
您无需添加Flow
,只需输入参数名称并选择文件即可。
答案 2 :(得分:3)
答案 3 :(得分:1)
是的,最新版本的邮递员进行了错误的更新。
但是,您可以下载postman的chrome扩展名并发送多个文件,但该文件仍然可以在其中使用。
编辑:我刚刚检查了一下,他们将其恢复了,但是如果您使用的是Chrome版本,则必须重新输入文件的键值。
但是现在可以正常工作了。
答案 4 :(得分:0)