I'm only a beginner with PHP and server side programming so excuse me for this question about variables. I was reading a tutorial about uploading a photo.
(tutorial on plus2net) and like described in the tutorial i directly copied and pasted the code after understanding it. However the webpage filled with following errors after i inserted PHP in to the HTML.
Notice: Use of undefined constant size - assumed 'size' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 44
Notice: Undefined index: file_up in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 44
Notice: Use of undefined constant file_up - assumed 'file_up' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 45
Notice: Use of undefined constant name - assumed 'name' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 45
Notice: Undefined index: file_up in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 45
Notice: Use of undefined constant file_up - assumed 'file_up' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 47
Notice: Use of undefined constant size - assumed 'size' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 47
Notice: Undefined index: file_up in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 47
Notice: Use of undefined constant file_up - assumed 'file_up' in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 51
This is the PHP Code:
<?Php
$file_upload="true";
$file_up_size=$_FILES['file_up'][size];
echo $_FILES[file_up][name];
if ($_FILES[file_up][size]>500000){
$msg=$msg."Uploaded file size more than 500KB<BR>";
$file_upload="false";}
if (!($_FILES[file_up][type] =="image/jpeg" OR $_FILES[file_up][type] =="image/png")){
$msg=$msg."Your uploaded file must be of JPG or PNG.<BR>";
$file_upload="false";}
$file_name=$_FILES[file_up][name];
$add="upload/$file_name"; //the path with the file name
if($file_upload=="true"){
if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){
//do your coding here to give a thanks message
}
else{
echo "Failed to upload file.";}
}
else{
echo $msg;
}
?>
I've corrected the variable error but I'm getting this error now instead
Notice: Undefined index: file_up in C:\Program Files (x86)\XAMPP\htdocs\college_ink\shirtDesign.php on line 44
Please guide me through this. :)