|
Posted by Rik Wasmus on 11/18/07 16:42
On Sun, 18 Nov 2007 16:47:17 +0100, bill <nobody@spamcop.net> wrote:
> ZeldorBlat wrote:
>> On Nov 18, 10:13 am, bill <nob...@spamcop.net> wrote:
>>> I want to extract the name of the photo uploaded.
>>>
>>> print_r of $_FILES yields:
>>> Files: Array ( [picture] =3D> Array ( [name] =3D>
>>> DSC_1802-saoirse-riona.jpg [type] =3D> image/jpeg [tmp_name] =3D>
>>> /tmp/phpJTspHZ [error] =3D> 0 [size] =3D> 76096 ) )
>>>
>>> so we have an array with one element, picture, that contains an
>>> array with an index, name, with a value of DSC_1802-saoirse-riona.jp=
g
>>>
>>> I get the correct value when I:
>>> $pic_name =3D $_FILES['picture']['name'];
>>> echo $pic_name
>>>
>>> however when I use:
>>>
>>> echo "<br />pic_name =3D $_FILES[picture][name]";
>>>
>>> I get:
>>> pic_name =3D Array[name]
>>>
>>> Why does the echo with the array reference not work while the
>>> assignment does ?
>>>
>>> bill
>> Put quotes around your array keys:
>> $_FILES['picture']['name']
>
> That, unfortunately, generates the dreaded:
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, =
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in...
Look at complex (curly) syntax:
<http://nl2.php.net/manual/en/language.types.string.php#language.types.s=
tring.parsing>
echo "<br />pic_name =3D {$_FILES['picture']['name']}";
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|