enveetee Posted November 19, 2015 Share Posted November 19, 2015 Hi My app sends out emails. Included in the email is a link to a PDF document which can be downloaded and views. The document(s) reside in different folders on the server, only known at creation time. My app can run from the root as well as a folder How can I get the url to the file for inclusion in the email. examples are http://www.myserver.com/docs/document1.pdf http://www.myserver.com/document2.pdf http://www.myserver.com/docs/anotherfolder/document1.pdf Thanks Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/ Share on other sites More sharing options...
requinix Posted November 19, 2015 Share Posted November 19, 2015 Well, perhaps you could stop putting these files all over your server and pick just one place for them. Path is known at creation time? Good. Path is only known at creation time? Well then the file just got lost because there is literally nothing else that knows the path to the file. So you should probably record that path somewhere during creation so you can retrieve it again later. Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526750 Share on other sites More sharing options...
enveetee Posted November 19, 2015 Author Share Posted November 19, 2015 I know where I created / copied the files to, and I store that location so I can retrieve it later; for example /thismonth /lastmonth /soontobedeleted I need to get a url to a known file in either of those folders Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526751 Share on other sites More sharing options...
requinix Posted November 19, 2015 Share Posted November 19, 2015 Umm... So, like, you'll have a file in /thismonth, and then move it into /lastmonth, and then move it into /soontobedeleted? Don't do that. If you want files in a directory according to the month, use a directory name for the month. Like "november-2015" or something. And then don't delete it later. If you really do have to delete it, delete the directories from 2+ months ago. Now, you say that you know where the files went and that you store that location to retrieve it later. What's stopping you from retrieving it now? Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526756 Share on other sites More sharing options...
enveetee Posted November 19, 2015 Author Share Posted November 19, 2015 Now, you say that you know where the files went and that you store that location to retrieve it later. What's stopping you from retrieving it now? ...because the url is different for each server Sometimes the app is in the root, sometimes in a sub folder Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526766 Share on other sites More sharing options...
requinix Posted November 19, 2015 Share Posted November 19, 2015 PHP only executes on one server at a time, so it doesn't matter if there's more than one server running this code. So basically, I'm saying these things like "put the file in one specific location" and "if you stored the location somewhere then look up that location again later" and you're saying those don't work. That's a problem because you don't really have any options besides that. Something has to give. Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526781 Share on other sites More sharing options...
Barand Posted November 19, 2015 Share Posted November 19, 2015 Store your pdf file locations relative to the root, not relative to your application. Then it doesn't matter which folder the application runs from Quote Link to comment https://forums.phpfreaks.com/topic/299525-creatinggetting-a-url-to-a-dynamically-created-file/#findComment-1526782 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.