bytesize Posted November 19, 2010 Share Posted November 19, 2010 I need help making img src work without using echo. The session has been started from another page. <?php $name = $_FILES['change']['name']['myfile']; $tmp_name = $_FILES['change']['tmp_name']['myfile']; if($name) { //start upload process $dblocation = "$name"; $location = "photos/$name"; move_uploaded_file($tmp_name,$location); $origloc = $location; $_SESSION['imglocation'] = $origloc; echo "<img src='../crop.php?h=50&w=50&f=$origloc' />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/ Share on other sites More sharing options...
Adam Posted November 19, 2010 Share Posted November 19, 2010 When you say from another page, do you mean another file that is included on this request, or from a completely different request? In-case of the latter, session_start must be called on EVERY request you want to use it. Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136701 Share on other sites More sharing options...
bytesize Posted November 19, 2010 Author Share Posted November 19, 2010 The session works. I did not want to include all of the code from the switch. The only reason I mentioned it is because someone asked on another post of mine if the session had been started. Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136704 Share on other sites More sharing options...
litebearer Posted November 19, 2010 Share Posted November 19, 2010 Not sure what you mean by 'not using echo'. You want the image to display, but without using the 'echo' command? Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136706 Share on other sites More sharing options...
laffin Posted November 19, 2010 Share Posted November 19, 2010 replace the echo with return and use something like this <?php function img_src() { include("img_src.php"); } echo img_src(); Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136710 Share on other sites More sharing options...
bytesize Posted November 19, 2010 Author Share Posted November 19, 2010 The image is copied to a folder and another script displays the image. photos/whatever.jpg is put into f and crop.php crops the image and copies it to crops/whatever.jpg <img src='../crop.php?h=50&w=50&f=photos/whatever.jpg' /> Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136718 Share on other sites More sharing options...
bytesize Posted November 19, 2010 Author Share Posted November 19, 2010 crop.php needs to run using <img src='../crop.php?h=50&w=50&f=$origloc' /> , it's the only way this will work. Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1136728 Share on other sites More sharing options...
laffin Posted November 20, 2010 Share Posted November 20, 2010 not really, the method i just gave will work as well, but your crop.php must be designed more as a function, and return the link. for example removal of the $_GET params to variables. Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1137091 Share on other sites More sharing options...
Adam Posted November 21, 2010 Share Posted November 21, 2010 You're not doing a great job of explaining the problem here. What is it you're trying to do exactly? As litlebearer asked a while back, what do you mean by not using 'echo'? Does the crop.php script return an image, otherwise why are you using an image tag to call a script that performs operations on the file system? Quote Link to comment https://forums.phpfreaks.com/topic/219207-run-script-without-echo/#findComment-1137446 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.