Join 307,140 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,751 people online right now. Registration is fast and FREE... Join Now!
Hi, I get this error message on my server everytime I try to upload a file to my database. Notice: Undefined index: userfile in C:\wamp\www\CourseWork\upload2.php on line 5
Notice: Undefined index: userfile in C:\wamp\www\CourseWork\upload2.php on line 6
Notice: Undefined index: userfile in C:\wamp\www\CourseWork\upload2.php on line 7
Notice: Undefined index: userfile in C:\wamp\www\CourseWork\upload2.php on line 8 Error uploading file.
PHP is case sensitive. The warning you get means that your variable is not defined. Look up your HTML <form> again. ['Userfile'] and ['userfile'] may look the same, but are completely different.
Thank you very much for the reply. But this is the entire block of codes.
CREATE TABLE upload2 ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(30) NOT NULL, type VARCHAR(30) NOT NULL, size INT NOT NULL, path VARCHAR(60) NOT NULL, PRIMARY KEY(id) );
Hi guys, I am unable to resolve the "Undefined Index" problem on my PHP code. Below are the blocks of codes for both the HTML as well as the PHP. Thank you.
$file_upload='true'; $file_up_size=$_FILES['file_up'][$size]; echo $_FILES['file_up'][$name]; if ($_FILES['file_up'][$size]>250000){$error=$error."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the
help page to know how to reduce the file size.<BR>"; $file_upload='false';} if (!($_FILES['file_up'][$type] =="image/jpeg" OR $_FILES['file_up'][$type] =="image/gif")){$error=$error."Your uploaded file must be of JPG or GIF. Other
file types are not allowed<BR>"; $file_upload='false';}
$file_name=$_FILES['file_up'][$name]; $add='uploaded/$file_name'; // the path with the file name where the file will be stored, upload is the directory name. if($file_upload=='true'){
if(move_uploaded_file ($_FILES['file_up'][$tmp_name], $add)){ // do your coding here to give a thanks message or any other thing. }else{echo "Failed to upload file Contact Site admin to fix the problem";}
}else{echo $error;} ?>
I will be most happy if anyone can help to resolve the Undefined Index it is given me on
QUOTE
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 3
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 4
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 5
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 6
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 7
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 10
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 11
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 12
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 14
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 14
Notice: Undefined index: file_up in C:\wamp\www\CourseWork\uploadck.php on line 17
Admin Edit: Please use code tags when posting your code. Code tags are used like so =>
Please, I am a beginner. Pardon me if I ask a stupid question. I just did that and I still get same errors. It is really frustrating! Please advice more. Thank you.