simora Posted July 5, 2020 Share Posted July 5, 2020 I am trying to get the actual filename so that I can attach it to an email. I tried echo $file; but its not giving me anything. Just a blank page. Here's the code that I' working with: $file = date('M-d-Y H:i A'). '.png'; $uri = substr($data,strpos($data,",")+1); file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); echo $file; exit; Quote Link to comment Share on other sites More sharing options...
requinix Posted July 6, 2020 Share Posted July 6, 2020 The "actual filename" will be file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); ./Collection_Posts/$file. If you can write to that file then you can read from it and attach it to an email too. Quote Link to comment Share on other sites More sharing options...
simora Posted July 6, 2020 Author Share Posted July 6, 2020 Hi requinix: That's what I thought also, but I've tried: $filename = ('./Collection_Posts/'.$file, base64_decode($uri)); Also $filename = file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); Also $filename = ./Collection_Posts/$file; Trying to echo the filename, I'm not getting anything. Quote Link to comment Share on other sites More sharing options...
requinix Posted July 6, 2020 Share Posted July 6, 2020 2 hours ago, simora said: Hi requinix: That's what I thought also, but I've tried: $filename = ('./Collection_Posts/'.$file, base64_decode($uri)); That is not valid PHP syntax. Besides, the base-64 stuff is for file_put_contents. Quote Also $filename = file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); According to the documentation, file_put_contents returns "the number of bytes that were written to the file". That does not help you. Quote Also $filename = ./Collection_Posts/$file; Close, except you're not using valid PHP syntax here either. Programming is not a matter of throwing stuff into your IDE until it works. You have to actually understand what things mean and how to use them. Copying and pasting stuff might eventually get you the right answer but it's going to be a pain in the butt until you get there. 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.