Hi everyone
I’m currently learning php and I’m finding it quite difficult :ne:
I’m trying to upload some pictures to the server using php however I keep getting this error:
“Notice: Undefined variable: img1_name in c:\program files\apache esting\upload.php on line 5
No input file”
Note: I’m testing this on my local machine, I’ve also tested it on the server. And the server does support php.
Here is the html code: (some of these code were from a tutorial)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload example</title>
</head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<p>File <input type="file" name="img1" size="30"> <input type="submit" name="submit" value="Send"></p>
</form>
</body>
</html>
Here is the php code:
<?php
/* upload.php */
if($img1_name != "") {
if($img1_size > 20000) {
echo "File size is bigger than 20KB";
exit;
} else {
@copy("$img1","/pictures/$img1_name") or die("No copy!");
}
} else {
die("No input file");
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Uploaded</title>
</head>
<body>
<p>File name <?php echo "$img1_name"; ?>,</p>
<p>File size <?php echo "$img1_size"; ?>,</p>
<p>File type <?php echo "$img1_type"; ?>.</p>
</body>
</html>
Any help would be great