Jump to content

uploading files and viewing them


patty mac

Recommended Posts

I'm taking a class and my instructor wants us to upload images and then send them on to another page.

 

Here is my uploading code:

<form method="post" action="page2.php" enctype="multipart/form-data">

<p>Choose a file to upload:

<input type="file" name="img1">

</p>

<input type="submit" name="submit" value="Upload Image 1!">

</form>

 

Then the next page has the following code..  then it has you upload another image and so on until you've uploaded three images and put them on the 5th page in a table .

 

<?php

 

$target_path = "uploads/";

 

$basename = "image1.jpg";

$target_path = $target_path . basename( $_FILES['img1']['name']);

 

if(move_uploaded_file($_FILES['img1']['tmp_name'], $target_path)) {

    echo "The file ".  basename( $_FILES['img1']['name']).

    " has been uploaded";

} else{

    echo "There was an error uploading the file, please try again!";

}

?>

 

We're suppose to call them image1.jpg, image2.jpg, image3.jpg.  The files (image_a.jpg, image_b.jpg and image_c.jpg) do upload and go into the uploads folder.  But I can't make them appear on the 5th page.  Syntax:

<form method="post" action="page5.php">

<table border="0" cellspacing="10" cellpadding="0">

  <tr>

    <td width="400"><img src="image1.jpg"  width="400" height="300" /></td>

    <td width="400"><img src="image2.jpg"  width="400" height="300" /></td>

    <td width="400"><img src="image3.jpg"  width="400" height="300" /></td>

  </tr>

</form>

 

There is more to it of course, but with this info is there any help you can give me?

 

Thanks!

Patty Mac

 

Link to comment
https://forums.phpfreaks.com/topic/127258-uploading-files-and-viewing-them/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.