Image Upload Question
Posted: Thu Jun 03, 2010 1:51 am
I tried this script that I found on the web, it upload the files, but it shows notices. Below are the notices. How can I fix these?
Notice: Undefined index: completed in C:\wamp\www\image upload2\image_upload.php on line 2
Notice: Undefined index: completed in C:\wamp\www\image upload2\image_upload.php on line 10
Please upload an image
Here is the code
Notice: Undefined index: completed in C:\wamp\www\image upload2\image_upload.php on line 2
Notice: Undefined index: completed in C:\wamp\www\image upload2\image_upload.php on line 10
Please upload an image
Here is the code
Code: Select all
<?php
if ($_REQUEST['completed'] == 1) {
$newname = uniqid("whc").".jpg";
move_uploaded_file($_FILES['mailfile']['tmp_name'],
"robdemo/$newname");
} ?>
<html>
<head><title>Upload page</title></head>
<body><h1>Image Uploader</h1>
<?php if ($_REQUEST['completed'] != 1) { ?>
<b>Please upload an image</b><br>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=1500000>
<input type=hidden name= 'completed' value=1>
Choose file to send: <input type=file name=mailfile> and
<input type=submit></form>
<?php } else { ?>
<b>Yum, Yum. I enjoyed that</b>
<?php } ?>
<hr>
Copyright, etc
</body></html>