Jump to content

manipulating where echo statement goes


bruckerrlb

Recommended Posts

I am trying to manipulate where my echo statement goes. Let me explain. I have a form that uploads a picture, if it is successful I want it to echo the path of the file, as well as the image itself. I figure I can get it to show the image with something like

 

<img src="imguploads/<?php echo $path ?>" />

 

This is the top part of my script right here

 

<?php
	include('db_connect.php');

	if(isset($_POST['submitvideo']))  {



  

if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "application/x-shockwave-flash")
|| ($_FILES["file"]["type"] == "application/octet-stream")
&& ($_FILES["file"]["size"] < 2000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {

    /*This is what I want to manipulate */
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    if (file_exists("imguploads/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"], "imguploads/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "imguploads/" . $_FILES["file"]["name"];
  
  
  //query to store path into database
  $thefile = $_FILES["file"]["name"];
  
  $query = "INSERT INTO images
	(id, imgpath)
	VALUES (0, '$thefile')";

	if (@mysql_query ($query)) {
	print 'Successfully Added!';
	}
   //end query
      }
    }
  }
else
  {
  echo "Invalid file";
  }
  
  }


?>


 

Once that passes, I want the info to come down to where the person originally submitted the picture. Any suggestions on how to do this is appreciated. Thanks

Link to comment
https://forums.phpfreaks.com/topic/78141-manipulating-where-echo-statement-goes/
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.