在blueimp的jquery文件上传器中访问文件上传数组

时间:2014-01-16 23:19:24

标签: php arrays

这个人多年来一直困扰着我。我正在使用blueimp的上传系统,它运行得非常好。下面我将发布我认为与我的问题相关的代码:

当我print_r($files)这就是我回来的时候:

Array
(
    [0] => stdClass Object
        (
            [name] => 16-01-14_QE5YHS.jpg
            [size] => 984576
            [type] => image/jpeg
            [url] => http://www.summersproperty.com/dashboard/uploads/HNI3Q3/16-01-14_QE5YHS.jpg
            [thumbnailUrl] => http://www.summersproperty.com/dashboard/uploads/HNI3Q3/thumbnail/16-01-14_QE5YHS.jpg
            [deleteUrl] => http://www.summersproperty.com/dashboard/uploads/?file=16-01-14_QE5YHS.jpg
            [deleteType] => DELETE
        )

)

$ files数组在这里设置我相信:

$files = array();
        if ($upload && is_array($upload['tmp_name'])) {
            // param_name is an array identifier like "files[]",
            // $_FILES is a multi-dimensional array:
            foreach ($upload['tmp_name'] as $index => $value) {
                $files[] = $this->handle_file_upload(
                    $upload['tmp_name'][$index],
                    $file_name ? $file_name : $upload['name'][$index],
                    $size ? $size : $upload['size'][$index],
                    $upload['type'][$index],
                    $upload['error'][$index],
                    $index,
                    $content_range
                );
            }
        }

它还返回一个JSON响应:

{"files":[{"name":"16-01-14_QE5YHS.jpg","size":984576,"type":"image\/jpeg","url":"http:\/\/www.summersproperty.com\/dashboard\/uploads\/HNI3Q3\/16-01-14_QE5YHS.jpg","thumbnailUrl":"http:\/\/www.summersproperty.com\/dashboard\/uploads\/HNI3Q3\/thumbnail\/16-01-14_QE5YHS.jpg","deleteUrl":"http:\/\/www.summersproperty.com\/dashboard\/uploads\/?file=16-01-14_QE5YHS.jpg","deleteType":"DELETE"}]}

我需要从数组中提取16-01-14_QE5YHS.jpg以用于使用GD编写的脚本。我试过了echo $files[0]['name'];。我确信这很简单,但我很困惑

1 个答案:

答案 0 :(得分:0)

它的访问方式如下:

$files[0]->name