-----Forwarded Message----- > From: Marco Tabini <[EMAIL PROTECTED]> > To: Naif Al-Otaibi <[EMAIL PROTECTED]> > 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