Re: Variable post as array
| From: | Pieter du Toit | Date: | Wed, 05 Mar 2008 13:27:37 +0000 |
| Subject: | Re: Variable post as array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271011@lists.php.net to get a copy of this message | ||
That is the problem, i can see the name of the file with $txtPhoto['name']
but when i use the same with temp_name, i get nothing, one weird thing is
this [error] => 0 [size] => 17008 , what is that?
this is the code that is giving the problem
$txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
filesize($txtPhoto)));
And this is the error
Warning: fopen() expects parameter 1 to be string, array given in
> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
I did not do the code im just trying to help out, if never use this kind of
code to work with photos, i normally use move_uploaded_file and put the path
in the databse, but it look like this code puts the photo in the database as
binary or something.
"Colin Guthrie" <gmane@colin.guthr.ie> wrote in message
news:fqm3de$6k1$1@ger.gmane.org...
> Pieter du Toit wrote:
>> I ran a print_r on it and this is the results
>>
>> Array ( [txtPhoto] => Array ( [name] => g1.jpg [type] => image/pjpeg
>> [tmp_name] => /tmp/php3qkA4A [error] => 0 [size] => 17008 ) )
>>
>> The image received here must be inserted into a database as binary it
>> looks
>> like it.
>
> "on it" is very vague dude. Be more specific... show code!!!
>
> From later posts it appears you are using register_globals to access the
> file as if it is a local variable.
>
> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
> filesize($txtPhoto)));
>
> For file upload elements $txtPhoto will be an array. use
> $txtPhoto['tmp_name'] or something. It's all in the manual.
>
> PS just avoid register globals anyway, it's evil.
>
> Col
>