Hello Folks. Thanks for all the help i have received here. I was trying to write an upload file. It was ok until i began error reporting. First i tried to inspect the file uploaded by asking the print_r to show the associate array of name, type, size, tmp_name and error. It works all right but it gives this error just as i load the page
Notice: Undefined index: file_upload in C:\wamp\www\btb _sandbox\upload .php on line 27
I didnt take it quite serious then i continues my error reporting. It gave the following errors
Notice: Undefined index: file_upload in C:\wamp\www\btb _sandbox\upload .php on line 18
Notice: Undefined index: in C:\wamp\www\btb _sandbox\upload .php on line 19
I understand that file_upload is undefined, but i dont know how to go around it. Or is it from my html tags? Please help out. Here is the code. Thanks
Notice: Undefined index: file_upload in C:\wamp\www\btb _sandbox\upload .php on line 27
I didnt take it quite serious then i continues my error reporting. It gave the following errors
Notice: Undefined index: file_upload in C:\wamp\www\btb _sandbox\upload .php on line 18
Notice: Undefined index: in C:\wamp\www\btb _sandbox\upload .php on line 19
I understand that file_upload is undefined, but i dont know how to go around it. Or is it from my html tags? Please help out. Here is the code. Thanks
Code:
<?php //In an application, this could be moved to a config file $upload_errors = array (//http://www.php.net/manual/en/features.file-upload.errors.php UPLOAD_ERR_OK => "No Errors.", UPLOAD_ERR_INI_SIZE => "Larger than upload_max_filesize.", UPLOAD_ERR_FORM_SIZE => "Larger than form MAX_FILE_SIZE.", UPLOAD_ERR_PARTIAL => "Partial upload.", UPLOAD_ERR_NO_FILE => "No file.", UPLOAD_ERR_NO_TMP_DIR => "No temporary directory", UPLOAD_ERR_CANT_WRITE => "Can't write to disk", UPLOAD_ERR_EXTENSION => "File upload stopped by extension." ); $error = $_FILES['file_upload']['error']; $message = $upload_errors[$error]; //print_r( is the one giving me Notice: Undefined index: file_upload in C:\wamp\www\btb_sandbox\upload.php on line 4. Echo makes it go, nut show nothing because it aint redable by humans echo "<pre>"; print_r($_FILES['file_upload']); echo "</pre>"; echo "<hr/>"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title> Upload </title> </head> <body> <?php if(!empty($message)){echo "<p>{$message}</p>";} //A means to pass messages to the the user about the from processing?> <form action="upload.php" enctype="multipart/form-data" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000000"/> <input type="file" name="file_upload"/> <input type="submit" value="Upload"/> </form> </body> </html>
Comment