Hai everybody,
Im trying to upload an image using a form by using POST method and another PHP file to receive and upload the file. I used the following lines of code and it shows some error and probably wrong output too.
It prints "No image found". It shows the same even if I use $_REQUEST['myimage'].
It prints "myimage" as undefined index and "name" as undefined variable if I use $_GET['myimage'].
(I have changed the form method type as GET, POST in index.php for the above test cases and got the above output)
Anybody pls help me.
Advanced Thanks...
Im trying to upload an image using a form by using POST method and another PHP file to receive and upload the file. I used the following lines of code and it shows some error and probably wrong output too.
Code:
//index.php <html> <body> <script language="javascript"> function preview() { document.STUDENT_PHOTO.src=document.myform.myimage.value; } </script> <form name="myform" method="POST" enctype="multipart/form-data" action="disp.php"> <img src="" alt="Click browse and locate the image." name="STUDENT_PHOTO" ID="STUDENT_PHOTO" height="170" width="170"/><BR /> <input type="file" name="myimage" onchange="preview()" /> <input type="submit"> </form> </body> </html> //disp.php <?PHP if(ISSET($_POST['myimage'])) { $student_photo=$name.$_FILES['myimage']['name']; //copy($_FILES['myimage']['tmp_name'],".\\images\\".$student_photo); echo $student_photo; } else { echo "No image found"; } ?>
It prints "myimage" as undefined index and "name" as undefined variable if I use $_GET['myimage'].
(I have changed the form method type as GET, POST in index.php for the above test cases and got the above output)
Anybody pls help me.
Advanced Thanks...
Comment