Re: [Fwd: Re: [PHP] Some error in file upload.]
| From: | Marco Tabini | Date: | Sat, 23 Nov 2002 13:23:55 +0000 |
| Subject: | Re: [Fwd: Re: [PHP] Some error in file upload.] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125730@lists.php.net to get a copy of this message | ||
Naif,
I think your problem is related to register_globals. The authors of the
book probably based their scripts on a version of PHP that had that
option turned on by default, but as 4.2.0, it's been turned off as it is
usually considered a security risk. So, either use the superglobal
arrays (like $_POST) to access your HTML form variables or turn
register_globals on in your php.ini file.
Cheers,
Marco
Marco
--
------------
php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com
On Sat, 2002-11-23 at 08:16, Naif Al-Otaibi wrote:
> Thanks, I fix this error but now I have another one:
> Notice: Undefined variable: action in c:\inetpub\wwwroot\php5
> \file_upload.php on line 45
>
> I have register_globals on
>
> > -----Forwarded Message-----
> >
> > > From: Marco Tabini <marcot@tabini.ca>
> > > To: Naif Al-Otaibi <naif@linux.org.sa>
> > > Subject: Re: [PHP] Some error in file upload.
> > > Date: 23 Nov 2002 07:56:06 -0500
> > >
> > > I think this needs changing:
> > >
> > > error-> if(isset(!$WINDIR) && !@unlink($userfile))
> > >
> > > into
> > >
> > > if(!isset($WINDIR) && !@unlink($userfile))
> > >
> > > Also, this would only work if you had register_globals on.
> > >
> > > Mind if I ask which book did you copy the example from?
> > >
> > >
> > > Marco
> > > --
> > > ------------
> > > php|architect - The magazine for PHP Professionals
> > > The monthly worldwide magazine dedicated to PHP programmers
> > > Check us out on the web at http://www.phparch.com
> > >
> > >
> > > On Sat, 2002-11-23 at 07:41, Naif Al-Otaibi wrote:
> > > >
> > > > I copy a complete example from a book to upload file and I got
> this
> > > > message error when I browse the file:
> > > >
> > > > Parse error: parse error, unexpected '!', expecting T_VARIABLE
> or '$'
> > > > in c:\inetpub\wwwroot\php5\file_upload.php on line 32
> > > >
> > > > Here is the content of the file (file_upload.php):
> > > >
> > > > <?
> > > > // file_upload.php
> > > > $archive_dir = "./docs";
> > > > function upload_form() {
> > > > global $PHP_SELF;
> > > > ?>
> > > >
> > > > <FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA"
> > > > ACTION="<? echo $PHP_SELF ?>">
> > > > <INPUT TYPE="HIDDEN" NAME="action"
VALUE="upload">
> > > > Upload file!
> > > > <INPUT TYPE="FILE" NAME="userfile">
> > > > <INPUT TYPE="SUBMIT" NAME="SUBMIT"
VALUE="upload">
> > > > </FORM>
> > > >
> > > > <?
> > > > }
> > > >
> > > > function upload_file() {
> > > > global $userfile, $userfile_name, $userfile_size,
> > > > $userfile_type, $archive_dir, $WINDIR;
> > > >
> > > > if(isset($WINDIR)) $userfile = str_replace
> > > > ("\\\\","\\",$userfile);
> > > >
> > > > $filename = basename($userfile_name);
> > > >
> > > > if($userfile_size <= 0) die ("$filename is empty.");
> > > >
> > > > if(!@copy($userfile, "$archive_dir/$filename"))
> > > > die ("Can't copy $userfile_name to $filename.");
> > > >
> > > > error-> if(isset(!$WINDIR) && !@unlink($userfile))
> > > > die ("Can't delete the file $userfile_name.");
> > > >
> > > > echo "$filename has been successfully uploaded.<BR>";
> > > > echo "Filesize: " . number_format($userfile_size) .
"<BR>";
> > > > echo "Filetype: $userfile_type<BR>";
> > > >
> > > > }
> > > > ?>
> > > > <HTML>
> > > > <HEAD><TITLE>FILE UPLOAD</TITLE></HEAD>
> > > > <BODY>
> > > > <?
> > > > if($action == 'upload') upload_file();
> > > > else upload_form();
> > > > ?>
> > > > </BODY>
> > > > </HTML>
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>