Question: Problem is from PHP Programming with MySQL Second Edition, Chapter, Exercise 5-5. I'm having a difficult time for my code to work correctly. I get
Problem is from "PHP Programming with MySQL" Second Edition, Chapter, Exercise 5-5. I'm having a difficult time for my code to work correctly. I get no errors when validating but my code doesn't display the enter name, description and uploading picture.
ReunionPictureUploader.php
Reunion Pictures Uploader
if(isset($_POST['upload'])) { if (empty($_POST['name'] || empty($_POST['caption']))) echo "Enter your name and a caption for the image. Refresh your page to upload page. ";
} else if (!isset($_FILES['image'])) { echo "Select an image to upload. Refresh you page to upload page. "; } else { $Name = addslashes($_POST['name']); $Caption = addslashes($_POST['caption']); $FileName = $Dir . "/" . $_FILES['image']['name']; $ImageList = foopen("imagefile.txt","ab");
if (is_writeable("imagefile.txt")) { if (fwrite($ImageList, $Name . "|" . $Caption . "|" . $FileName . " ")) echo "The uploading is successful. Thank you for uploading the picture! "; else echo "Cannot upload your picture to our site. "; } else echo "Cannot write to the file. "; fclose($ImageList); } if(isset($_FILES['image'])) { if(move_uploaded_file($_FILES['image']['tmp_name'],$Dir . "/" . $_FILES['image']['name'])==TRUE) echo "File \"".htmlentities($_FILES['image']['name']). "\"The image is successfully uploaded. "; else { echo "There was an error in uploading \"".htmlentities($_FILES['image']['name'])."\". "; }
}
?>
This program contains a form for the user for them to enter in their name, a caption for an image, and then upload an image.
Course Homepage
HTML5 Validation
ReunionImage.php
Reunion Pictures
Upload another image
This program contains a form for the user for them to enter in their name, a caption for an image, and then upload an image.
Course Homepage
HTML5 Validation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
