bruckerrlb Posted November 29, 2007 Share Posted November 29, 2007 Hello, I have a form, where the user uploads images, this works fine, but once the image is uploaded I would like to have the page refreshed with the specific image that the user uploaded. I have it set up so that when the user uploads the image, it goes into a specific folder, like so move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); echo "Stored in: " . "uploads/" . $_FILES["file"]["name"]; So my question is how can I get the image to show up in the user section so that they can see what image they've just uploaded. Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/ Share on other sites More sharing options...
obsidian Posted November 29, 2007 Share Posted November 29, 2007 If you're wanting to show the image, you need to echo an image tag instead of just the location: echo "<img src=\"uploads/{$_FILES['file']['name']}\" />\n"; Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402078 Share on other sites More sharing options...
bruckerrlb Posted November 29, 2007 Author Share Posted November 29, 2007 Thanks, just one more question, I have all of this code above the html tags of my page, because it's a server submit, and I am wondering how I can echo this down to the specific area of the web page i'd like it to go to Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402089 Share on other sites More sharing options...
eon201 Posted November 29, 2007 Share Posted November 29, 2007 You can open and close php wherever you wish on a page. So therefore lets say your page looks something like this... <?php //Here is all of your php code ?> <html> <head> </head> <body> <?php echo "<img src=\"uploads/{$_FILES['file']['name']}\" />\n"; ?> </body> </html> You can open and close the php tags pretty much anywhere you wish on a page and call previous variables/arrays. I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402091 Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Use CSS Thanks, just one more question, I have all of this code above the html tags of my page, because it's a server submit, and I am wondering how I can echo this down to the specific area of the web page i'd like it to go to Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402104 Share on other sites More sharing options...
eon201 Posted November 29, 2007 Share Posted November 29, 2007 Sorry... Did I miss understand the question?? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402112 Share on other sites More sharing options...
obsidian Posted November 29, 2007 Share Posted November 29, 2007 Sorry... Did I miss understand the question?? :-\ Don't think so... I think that revraz did. Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402115 Share on other sites More sharing options...
bruckerrlb Posted November 29, 2007 Author Share Posted November 29, 2007 Thanks, I understand the gist of it, but when I put the echo statement below the html code, it doesn't seem to show up. I have something like this move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); $filepath = $_FILES["file"]["name"]; echo "Stored in: " . "uploads/" . $_FILES["file"]["name"]; echo "<div class\"imgdynamic\"><img src=\"uploads/$filepath\" /></div>"; What i'd like to do is move it into this section <p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submitvideo" value="add image" /> </form> </p> <!--right here under the code --> When I put the echo statement there, no image showed up, and I suppose it's because I have an end statement, and I would normally just keep the statement open until I absolutly need to close it, but I can't keep it open because I have other php i'm trying to call, such as <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> And I do believe that if I keep the statement open i'll give myself an infinite loop, which I fear. I have tried using css, but it still doesn't seem to show up where I need it. I appreciate the answers I am getting great feedback! Quote Link to comment https://forums.phpfreaks.com/topic/79424-making-an-echo-statement-a-variable/#findComment-402133 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.