我调用upload函数并返回一个变量。当我var_dump($x)
时,它会显示以下内容:
{"files":[{"name":"1004046_469695273124093_104592888_n_1_28860.jpg","size":0,"type":"image\/jpeg","error":"abort","delete_url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/?file=1004046_469695273124093_104592888_n_1_28860.jpg","delete_type":"DELETE"}]}array(1) {
["files"]=>
array(1) {
[0]=> object(stdClass)#24 (6) {
["name"]=> string(47) "1004046_469695273124093_104592888_n_1_28860.jpg"
["size"]=> int(0)
["type"]=> string(10) "image/jpeg"
["error"]=> string(5) "abort"
["delete_url"]=> string(104) "http://www.xxx.com/upload/uploader/server/php/?file=1004046_469695273124093_104592888_n_1_28860.jpg"
["delete_type"]=> string(6) "DELETE"
}
}
}
我尝试var_dump(json_decode($x))
,结果为NULL。
我的问题是如何从这个???
获取值名称尝试了这两个:
echo $x->files[0]->name;
echo " ********************** ";
echo $x['files'][0]->name;
echo " ********************** ";
,结果是
{"files":[{"name":"1004046_469695273124093_104592888_n_1_14299.jpg","size":78289,"type":"image\/jpeg","url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/files\/1004046_469695273124093_104592888_n_1_14299.jpg","thumbnail_url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/files\/thumbnail\/1004046_469695273124093_104592888_n_1_14299.jpg","delete_url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/?file=1004046_469695273124093_104592888_n_1_14299.jpg","delete_type":"DELETE"}]}{"files":[{"name":"1004046_469695273124093_104592888_n_1_12920.jpg","size":0,"type":"image\/jpeg","error":"abort","delete_url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/?file=1004046_469695273124093_104592888_n_1_12920.jpg","delete_type":"DELETE"}]}
**********************
{"files":[{"name":"1004046_469695273124093_104592888_n_1_15697.jpg","size":0,"type":"image\/jpeg","error":"abort","delete_url":"http:\/\/www.xxx.com\/upload\/uploader\/server\/php\/?file=1004046_469695273124093_104592888_n_1_15697.jpg","delete_type":"DELETE"}]}1004046_469695273124093_104592888_n_1_15697.jpg
**********************
答案 0 :(得分:3)
你试过了吗?
$name_val = $x->files[0]->name;
答案 1 :(得分:0)
$_FILES['files']['error'];
$_FILES['files']['name'];