Saturday, 15 February 2014

PHP and HTML Undefined Index on file upload -



PHP and HTML Undefined Index on file upload -

here html code

<html> <head> <title>upload file</title> </head> <body> <h1>upload file</h1> <form method="post" action="php3.php"> <strong>file upload:</strong><br> <input type="file" name="txt1" size="50"> <p><input type="submit" name="submit" value="upload file"></p> </form> </body> </html>

and here php code

if ($_files['txt1'] != '') { mkdir("c:/xampp/cis64/"); //creates cis64 directory $filename = "c:/xampp/cis64/"; //location of file copy($_files['txt1']['tmp_name'], $filename.$_files['txt1']['name']) or die("couldn't re-create file."); //copies uploaded file cis64 directory } else { die("no input file specified"); //if file doesn't open, close program. }

for reason error: "undefined index: txt1 in c:\xampp\htdocs\php3.php on line 11" working before , of sudden stopped working. wrong code?

check

if (!empty($_files['txt1']))

because @ time when form not posted there nil $_post['txt1']

and <form method="post" action="php3.php"> should <form method="post" action="php3.php" enctype="multipart-formdata"> file uploading.

php html indexing undefined

No comments:

Post a Comment