简体   繁体   中英

Access file upload array in blueimp's jquery file uploader

This one's been bugging me for ages. I'm using blueimp's upload system which is working really well. Below i will post the code i believe to be relevant to my issue:

When i print_r($files) this is what i get back:

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
        )

)

The $files array is set up here i believe:

$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
                );
            }
        }

It also returns a JSON response which is:

{"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"}]}

I need to extract 16-01-14_QE5YHS.jpg from the array to use in a script im writing with GD. I have tried echo $files[0]['name']; . I'm sure it's something simple but i'm so confused

可以这样访问:

$files[0]->name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM