toxictoad Posted December 12, 2008 Share Posted December 12, 2008 I have this code working if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br /><br />"; } else { echo "Sorry, there was a problem uploading your file."; } ?> What I don't get is how to take what's being echoed in the else statements and have it in the HTML code. Can anyone help? Thanks TT Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 <?php if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $uploadResult = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br /><br />"; } else { $uploadResult = "Sorry, there was a problem uploading your file."; } ?> Then in your html put <?php echo $uplaodResult; ?> where ever you want it Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 12, 2008 Share Posted December 12, 2008 Exactly like that. You won gevans. Quote Link to comment Share on other sites More sharing options...
toxictoad Posted December 12, 2008 Author Share Posted December 12, 2008 thanks guys, I was playing with it and figured it out, I did it a little different though $success="The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br /><br />"; $error= "Sorry, there was a problem uploading your file."; then use <?=$success?><?=$error?> in the HTML code but your use of just $uploadResult will just mean that I only need to add <?=$uploadResult?> so thanks Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 this is an old way of doing things <?=$success?> please use <?php echo $success; ?> Quote Link to comment Share on other sites More sharing options...
toxictoad Posted December 12, 2008 Author Share Posted December 12, 2008 this is an old way of doing things <?=$success?> please use <?php echo $success; ?> Ok thank's, picking it up as I go Before I mark it as solved would there be a way of adding a different graphic to each of these statements? Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 $error= "<div>Sorry, there was a problem uploading your file.</div><div><img src=\"yourimage.jpg\" alt=\"\" /></div>"; Just shove your html in there!! and dont forget to escape your quotes (if needed) Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 12, 2008 Share Posted December 12, 2008 this is an old way of doing things <?=$success?> please use <?php echo $success; ?> Yeh, its an old way. you can do this now also. but have to configure you php.ini file. Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 @mmarif4u it can be done, but is not recommended Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 12, 2008 Share Posted December 12, 2008 @mmarif4u it can be done, but is not recommended You are right, not recommended. it was until php4. Quote Link to comment Share on other sites More sharing options...
toxictoad Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks gevans I'm slowly picking up the basics both <?=$success?> and <?php echo $success; ?> work so guess the server's setup ok, I'll stick to <?php echo $success; ?> Thanks again Quote Link to comment 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.