Re: uploading images
| From: | Misha Peric | Date: | Tue, 24 Jun 2003 07:17:18 +0000 |
| Subject: | Re: uploading images | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152568@lists.php.net to get a copy of this message | ||
fopen() returns FALSE if it fails, and that's probably what happends here.
$_POST is superglobal so register_globals doesn't mean anything to it. Just
use the proper functions for filename and filesize:
$_FILES['userfile']['name']
$_FILES['userfile']['size']
Of course you should move the uploaded file from it temporary location
somewhere in the script. Look "Chapter 18. Handling file uploads" for
further details ...
Misha Peric
"Tyler Longren" <tyler@jdhost.com> wrote in message
news:000701c339d0$79f7a740$0101a8c0@jdwsnotebook...
> Hi,
>
> I'm trying to upload a small image via a form. This code worked with php
> versions prior to 4.1.0. I assume it would still work if register_globals
> was turned on.
>
> Here's the error:
> Warning: fread(): supplied argument is not a valid stream resource in
> /home/sites/site2/users/tyler/web/upload.php on line 28
>
> And here's line 28:
> $data = fread(fopen($_POST['binFile'], "r"),
> filesize($_POST['binFile']));
>
> Am I doing that correctly? If you need to see more code, let me know.
>
> Thanks everyone!
> Tyler Longren
>