Undefined variables errors are errors of level
E_NOTICE. Instead of if ($File) use if (isset($File))
or similiar (such as empty()). Depending on your
mission. A similiar example:
if (empty($form_submitted)) {
include 'form.html';
} else {
include 'process_form.php';
}
It's worth mentioning that one can control error
levels both at runtime (error_reporting()) as
well as in php.ini (.htaccess, etc).
Regards,
Philip Olson
On Tue, 30 Apr 2002, TGL wrote:
> I'm new to PHP and can't get through my first script. I want to create a
> form that will allow the user to attach a file. I started with the file
> upload part of the form thinking that it ould give me the most problem, and
> it has.
>
> This is the error message that shows when I view the page in the browser:
>
> Warning: Undefined variable: File in
> D:\inetpub\thegospellady\www\kia\form.php on line 8
> here is the url to the form: http://www.thegospellady.com/kia/form.php
>
> Please help.
>
> <?php
> /* This next conditional determines whether or not to handle the form,
> depending upon whether or not $File exists. */
> if($File) {
> print ("File name: $File_name<P>\n");
> print ("File size: $File_size<P>\n");
> if(copy($File, "/users/$File_name")) {
> print ("Your file was successfully uploaded!<P>\n");
> } else {
> print ("Your file could not be copied.<P>\n");
> }
> unlink($File);
> }
>
> print ("Upload a file to the server:\n");
> print ("<FORM ACTION=\"form.php\" METHOD=POST
> ENCTYPE=\"multipart/form-data\">\n");
> print ("File <INPUT TYPE=FILE NAME=\"File\" SIZE=20><BR>\n");
> print ("<INPUT TYPE=SUBMIT NAME=\"SUBMIT\" VALUE=\"Submit!\"></FORM>\n");
> ?>
>
>
>
> --
> 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