Jump to content

uploading pictures to a form in php


Recommended Posts

I am new to PHP and I am having some problems and I am hoping someone can point me in the right direction. Here is what I need to do:

Create a Web Form for uploading pictures for a high school reunion. The form should have text input fields for the person's name and a description of the image, and a file input field for the image. To accompany each file, create a text file that contains the name and description of the image. Create a separate Web Page that displays the pictures with a caption showing the name and description fields. Make sure the folder has read and write for everyone.

Here is what I have but it isnt working properly:

  • Process page of the page!
  • an errow here: This is the message I get!
    Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR) in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 5\R.E.5-5_FillPictureForm.php on line 28 which deals with the picture!

    • My problem is that it is having a problem uploading a picture and showing it!

  • How do I fix the issue with uploading a picture and then showing it!

  • Input page
<form method="POST" action="R.E.5-5_Fillrrr.php">

<p>Name <input type="text" name="name"
<p>Description <input type="text" name="description"
<p>Choose a file to upload: <input type = "file" name = "picture" accept = "image/*"
<p><input type="submit" value="Submit" /></p>
<p><a href="R.E.5-5_ShowPictures.php">Show Pictures


  • Processing page!

if (empty($_POST['name']) || empty($_POST['description']))
	echo "<p>You must enter your name and description about
		 your picture. Click your browser's Back button 
	     to return to the Picture Input Page!</p>\n";
else {
	$Name = addslashes($_POST['name']);
	$Description = addslashes($_POST['description']);
	$Picture = addslashes($_POST['picture']);
	$ShowPic = fopen("showpic.txt", "ab");
	if (is_writeable("showpic.txt)) {
		if (fwrite($ShowPic, $Name . "," . $Description . "," .
				$Picture . "\r\n"))
		echo "<p>Thank you for filling out the Picture Input Page!</p>\n";
		echo "<p>Cannot add your name to the Picture Input Page!</p>\n";
 		echo "<p>Cannot write to the file.</p>\n";
?><!--End PHP Script-->


Edited by jameshay
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.